Skip to content

Commit bb663cb

Browse files
author
Vasyl Vavrychuk
committed
fixed compilation errors in native/hybrid/quick tests
Change-Id: Idbdc950afc51399806cf62f59c7fa0752da382fb Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@globallogic.com>
1 parent 1cc5603 commit bb663cb

19 files changed

+161
-134
lines changed

java/client/test/org/openqa/selenium/qtwebkit/hybridtests/InternalWebViewTest.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@
3030
import org.openqa.selenium.WaitingConditions;
3131
import org.openqa.selenium.WebDriver;
3232
import org.openqa.selenium.WebElement;
33+
import org.openqa.selenium.support.ui.ExpectedCondition;
3334
import org.openqa.selenium.testing.JUnit4TestBase;
3435

3536
import java.util.concurrent.Callable;
3637

3738
import static org.junit.Assert.fail;
39+
import static org.openqa.selenium.support.ui.ExpectedConditions.titleIs;
3840

3941
public class InternalWebViewTest extends JUnit4TestBase {
4042

@@ -58,7 +60,7 @@ public void testCanGetUrlFromInternalWebView() {
5860
for (String winHandle : driver.getWindowHandles()) {
5961
if (!currentWindow.equals(winHandle)) {
6062
driver.switchTo().window(winHandle);
61-
waitFor(windowUrlContains(driver, "colorPage.html"));
63+
wait.until(windowUrlContains(driver, "colorPage.html"));
6264
break;
6365
}
6466
}
@@ -83,15 +85,15 @@ public void testCanNotLoadNotExistIntoWebView() {
8385
inputUrl.sendKeys(pages.notExist);
8486
btnLoad.click();
8587
WebElement label = driver.findElement(By.id("labelTitle"));
86-
waitFor(labelContains(label, "Not Found"));
88+
wait.until(labelContains(label, "Not Found"));
8789
}
8890

8991
@Test
9092
public void testCanNotLoadWidgetIntoWebView() {
9193
inputUrl.sendKeys("qtwidget://FindingTestWidget");
9294
btnLoad.click();
9395
WebElement label = driver.findElement(By.id("labelTitle"));
94-
waitFor(labelNoContains(label, "Here Will Be HTML Title"));
96+
wait.until(labelNoContains(label, "Here Will Be HTML Title"));
9597
}
9698

9799
@Test
@@ -169,27 +171,30 @@ public void testCanNotMaximizeInternalView() {
169171
private WebElement btnLoad;
170172
private String currentWindow;
171173

172-
private Callable<Boolean> windowUrlContains(final WebDriver webdriver, final String url) {
173-
return new Callable<Boolean>() {
174-
public Boolean call() throws Exception {
174+
private ExpectedCondition<Boolean> windowUrlContains(final WebDriver webdriver, final String url) {
175+
return new ExpectedCondition<Boolean>() {
176+
@Override
177+
public Boolean apply(WebDriver input) {
175178
String currentUrl = webdriver.getCurrentUrl();
176179
return currentUrl.contains(url);
177180
}
178181
};
179182
}
180183

181-
private Callable<Boolean> labelContains(final WebElement elem, final String text) {
182-
return new Callable<Boolean>() {
183-
public Boolean call() throws Exception {
184+
private ExpectedCondition<Boolean> labelContains(final WebElement elem, final String text) {
185+
return new ExpectedCondition<Boolean>() {
186+
@Override
187+
public Boolean apply(WebDriver input) {
184188
String current = elem.getText();
185189
return current.contains(text);
186190
}
187191
};
188192
}
189193

190-
private Callable<Boolean> labelNoContains(final WebElement elem, final String text) {
191-
return new Callable<Boolean>() {
192-
public Boolean call() throws Exception {
194+
private ExpectedCondition<Boolean> labelNoContains(final WebElement elem, final String text) {
195+
return new ExpectedCondition<Boolean>() {
196+
@Override
197+
public Boolean apply(WebDriver input) {
193198
String current = elem.getText();
194199
return !current.contains(text);
195200
}

java/client/test/org/openqa/selenium/qtwebkit/hybridtests/WidgetAndWebViewTest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
2727
import org.openqa.selenium.WaitingConditions;
2828
import org.openqa.selenium.WebDriver;
2929
import org.openqa.selenium.WebElement;
30+
import org.openqa.selenium.support.ui.ExpectedCondition;
3031
import org.openqa.selenium.testing.JUnit4TestBase;
3132

3233
import java.util.concurrent.Callable;
3334

3435
import static org.junit.Assert.assertEquals;
36+
import static org.openqa.selenium.support.ui.ExpectedConditions.titleIs;
3537

3638
public class WidgetAndWebViewTest extends JUnit4TestBase {
3739

@@ -67,7 +69,7 @@ public void testCanGetUrlFromWebView() {
6769
for (String winHandle : driver.getWindowHandles()) {
6870
if (!currentWindow.equals(winHandle)) {
6971
driver.switchTo().window(winHandle);
70-
waitFor(windowUrlContains(driver, "colorPage.html"));
72+
wait.until(windowUrlContains("colorPage.html"));
7173
break;
7274
}
7375
}
@@ -144,10 +146,11 @@ public void testCheckNumberOfWindows() {
144146
private WebElement button;
145147

146148

147-
private Callable<Boolean> windowUrlContains(final WebDriver webdriver, final String url) {
148-
return new Callable<Boolean>() {
149-
public Boolean call() throws Exception {
150-
String currentUrl = webdriver.getCurrentUrl();
149+
private ExpectedCondition<Boolean> windowUrlContains(final String url) {
150+
return new ExpectedCondition<Boolean>() {
151+
@Override
152+
public Boolean apply(WebDriver driver) {
153+
String currentUrl = driver.getCurrentUrl();
151154
return currentUrl.contains(url);
152155
}
153156
};

java/client/test/org/openqa/selenium/qtwebkit/hybridtests/WindowWithDeclarativeViewTest.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.openqa.selenium.Point;
3030
import org.openqa.selenium.WebDriver;
3131
import org.openqa.selenium.WebElement;
32+
import org.openqa.selenium.support.ui.ExpectedCondition;
3233
import org.openqa.selenium.testing.JUnit4TestBase;
3334

3435
import java.util.concurrent.Callable;
@@ -57,7 +58,7 @@ public void testCanGetUrlFromInternalDeclarativeView() {
5758
for (String winHandle : driver.getWindowHandles()) {
5859
if (!currentWindow.equals(winHandle)) {
5960
driver.switchTo().window(winHandle);
60-
waitFor(windowUrlContains(driver, "FindingTest.qml"));
61+
wait.until(windowUrlContains(driver, "FindingTest.qml"));
6162
break;
6263
}
6364
}
@@ -68,15 +69,15 @@ public void testCanNotLoadNotExistIntoDeclarativeView() {
6869
inputUrl.sendKeys(appServer.whereIs("quick1/NoExist.qml"));
6970
btnLoad.click();
7071
WebElement label = driver.findElement(By.id("labelStatus"));
71-
waitFor(labelContains(label, "Error"));
72+
wait.until(labelContains(label, "Error"));
7273
}
7374

7475
@Test
7576
public void testCanNotLoadWidgetIntoDeclarativeView() {
7677
inputUrl.sendKeys("qtwidget://FindingTestWidget");
7778
btnLoad.click();
7879
WebElement label = driver.findElement(By.id("labelStatus"));
79-
waitFor(labelContains(label, "Error"));
80+
wait.until(labelContains(label, "Error"));
8081
}
8182

8283
@Test
@@ -154,18 +155,20 @@ public void testCanNotMaximizeInternalView() {
154155
private WebElement btnLoad;
155156
private String currentWindow;
156157

157-
private Callable<Boolean> windowUrlContains(final WebDriver webdriver, final String url) {
158-
return new Callable<Boolean>() {
159-
public Boolean call() throws Exception {
158+
private ExpectedCondition<Boolean> windowUrlContains(final WebDriver webdriver, final String url) {
159+
return new ExpectedCondition<Boolean>() {
160+
@Override
161+
public Boolean apply(WebDriver input) {
160162
String currentUrl = webdriver.getCurrentUrl();
161163
return currentUrl.contains(url);
162164
}
163165
};
164166
}
165167

166-
private Callable<Boolean> labelContains(final WebElement elem, final String text) {
167-
return new Callable<Boolean>() {
168-
public Boolean call() throws Exception {
168+
private ExpectedCondition<Boolean> labelContains(final WebElement elem, final String text) {
169+
return new ExpectedCondition<Boolean>() {
170+
@Override
171+
public Boolean apply(WebDriver input) {
169172
String current = elem.getText();
170173
return current.contains(text);
171174
}

java/client/test/org/openqa/selenium/qtwebkit/hybridtests/WindowWithSeparatedDeclarativeAndWebViewsTest.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.openqa.selenium.WaitingConditions;
3030
import org.openqa.selenium.WebDriver;
3131
import org.openqa.selenium.WebElement;
32+
import org.openqa.selenium.support.ui.ExpectedCondition;
3233
import org.openqa.selenium.testing.JUnit4TestBase;
3334

3435
import java.util.concurrent.Callable;
@@ -38,6 +39,7 @@
3839
import static org.junit.Assert.assertNotNull;
3940
import static org.junit.Assert.assertTrue;
4041
import static org.junit.Assert.fail;
42+
import static org.openqa.selenium.support.ui.ExpectedConditions.titleIs;
4143

4244
public class WindowWithSeparatedDeclarativeAndWebViewsTest extends JUnit4TestBase {
4345

@@ -70,7 +72,7 @@ public void testCanGetUrlFromQmlView() {
7072
for (String winHandle : driver.getWindowHandles()) {
7173
if (!currentWindow.equals(winHandle)) {
7274
driver.switchTo().window(winHandle);
73-
waitFor(windowUrlContains(driver, "FindingTest.qml"));
75+
wait.until(windowUrlContains(driver, "FindingTest.qml"));
7476
break;
7577
}
7678
}
@@ -111,7 +113,7 @@ public void testCanSwitchBetweenQmlViewAndWebView() {
111113
if (!currentWindow.equals(winHandle)) {
112114
webWindow = winHandle;
113115
driver.switchTo().window(webWindow);
114-
waitFor(windowUrlContains(driver, "colorPage.html"));
116+
wait.until(windowUrlContains(driver, "colorPage.html"));
115117
break;
116118
}
117119
}
@@ -125,14 +127,14 @@ public void testCanSwitchBetweenQmlViewAndWebView() {
125127
if (!currentWindow.equals(winHandle)) {
126128
if (!webWindow.equals(winHandle)) {
127129
driver.switchTo().window(winHandle);
128-
waitFor(windowUrlContains(driver, "ClickTest.qml"));
130+
wait.until(windowUrlContains(driver, "ClickTest.qml"));
129131
break;
130132
}
131133
}
132134
}
133135

134136
driver.switchTo().window(webWindow);
135-
waitFor(windowUrlContains(driver, "colorPage.html"));
137+
wait.until(windowUrlContains(driver, "colorPage.html"));
136138
}
137139

138140
@Test
@@ -144,7 +146,7 @@ public void testCanOpenQmlViewAndWebViewTogether() {
144146
if (!currentWindow.equals(winHandle)) {
145147
qmlWindow = winHandle;
146148
driver.switchTo().window(qmlWindow);
147-
waitFor(windowUrlContains(driver, "ClickTest.qml"));
149+
wait.until(windowUrlContains(driver, "ClickTest.qml"));
148150
break;
149151
}
150152
}
@@ -157,7 +159,7 @@ public void testCanOpenQmlViewAndWebViewTogether() {
157159
if (!currentWindow.equals(winHandle)) {
158160
if (!qmlWindow.equals(winHandle)) {
159161
driver.switchTo().window(winHandle);
160-
waitFor(windowUrlContains(driver, "colorPage.html"));
162+
wait.until(windowUrlContains(driver, "colorPage.html"));
161163
break;
162164
}
163165
}
@@ -174,7 +176,7 @@ public void testCanOpenAndCloseQmlViewAndWebView() {
174176
if (!currentWindow.equals(winHandle)) {
175177
qmlWindow = winHandle;
176178
driver.switchTo().window(qmlWindow);
177-
waitFor(windowUrlContains(driver, "ClickTest.qml"));
179+
wait.until(windowUrlContains(driver, "ClickTest.qml"));
178180
break;
179181
}
180182
}
@@ -191,7 +193,7 @@ public void testCanOpenAndCloseQmlViewAndWebView() {
191193
if (!qmlWindow.equals(winHandle)) {
192194
webWindow = winHandle;
193195
driver.switchTo().window(webWindow);
194-
waitFor(windowUrlContains(driver, "colorPage.html"));
196+
wait.until(windowUrlContains(driver, "colorPage.html"));
195197
break;
196198
}
197199
}
@@ -221,7 +223,7 @@ public void testCanDownloadQmlIntoNoParentView() {
221223
}
222224
}
223225
driver.get(appServer.whereIs("quick1/FindingTest.qml"));
224-
waitFor(windowUrlContains(driver, "FindingTest.qml"));
226+
wait.until(windowUrlContains(driver, "FindingTest.qml"));
225227
}
226228

227229
@Test
@@ -249,7 +251,7 @@ public void testCanNotLoadWebViewToQmlView() {
249251
for (String winHandle : driver.getWindowHandles()) {
250252
if (!currentWindow.equals(winHandle)) {
251253
driver.switchTo().window(winHandle);
252-
waitFor(windowUrlContains(driver, "colorPage.html"));
254+
wait.until(windowUrlContains(driver, "colorPage.html"));
253255
break;
254256
}
255257
}
@@ -273,9 +275,10 @@ public void testCheckNumberOfWindows() {
273275
private WebElement inputQmlURL;
274276
private WebElement buttonToQml;
275277

276-
private Callable<Boolean> windowUrlContains(final WebDriver webdriver, final String url) {
277-
return new Callable<Boolean>() {
278-
public Boolean call() throws Exception {
278+
private ExpectedCondition<Boolean> windowUrlContains(final WebDriver webdriver, final String url) {
279+
return new ExpectedCondition<Boolean>() {
280+
@Override
281+
public Boolean apply(WebDriver input) {
279282
String currentUrl = webdriver.getCurrentUrl();
280283
return currentUrl.contains(url);
281284
}

java/client/test/org/openqa/selenium/qtwebkit/nativetests/ClickTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import static org.junit.Assert.assertTrue;
2828
import static org.junit.Assert.assertEquals;
2929
import static org.junit.Assert.fail;
30+
import static org.openqa.selenium.support.ui.ExpectedConditions.titleIs;
3031

3132
import org.openqa.selenium.*;
3233
import org.openqa.selenium.testing.JUnit4TestBase;

java/client/test/org/openqa/selenium/qtwebkit/nativetests/ElementSelectingTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
import org.junit.Test;
2222
import org.openqa.selenium.By;
2323
import org.openqa.selenium.WebElement;
24+
import org.openqa.selenium.support.ui.ExpectedConditions;
2425
import org.openqa.selenium.testing.JUnit4TestBase;
2526

2627
import static org.junit.Assert.assertEquals;
2728
import static org.junit.Assert.assertThat;
2829
import static org.junit.Assert.assertTrue;
29-
import static org.openqa.selenium.WaitingConditions.elementSelectionToBe;
3030

3131
import static org.hamcrest.Matchers.is;
3232

@@ -147,36 +147,36 @@ public void testClickingDisabledUnselectedRadioButtonShouldBeNoop() {
147147
}
148148

149149

150-
private static void assertNotSelected(WebElement element) {
150+
private void assertNotSelected(WebElement element) {
151151
assertSelected(element, UNSELECTED);
152152
}
153153

154-
private static void assertSelected(WebElement element) {
154+
private void assertSelected(WebElement element) {
155155
assertSelected(element, SELECTED);
156156
}
157157

158-
private static void assertSelected(WebElement element, boolean isSelected) {
159-
waitFor(elementSelectionToBe(element, isSelected));
158+
private void assertSelected(WebElement element, boolean isSelected) {
159+
wait.until(ExpectedConditions.elementSelectionStateToBe(element, isSelected));
160160
assertThat(
161161
String.format("Expected element %s to be %s but was %s",
162162
describe(element), selectedToString(isSelected), selectedToString(!isSelected)),
163163
element.isSelected(), is(isSelected));
164164
}
165165

166-
private static void assertCannotSelect(WebElement element) {
166+
private void assertCannotSelect(WebElement element) {
167167
boolean previous = element.isSelected();
168168
element.click();
169169
assertEquals(previous, element.isSelected());
170170
}
171171

172-
private static void assertCanSelect(WebElement element) {
172+
private void assertCanSelect(WebElement element) {
173173
assertNotSelected(element);
174174

175175
element.click();
176176
assertSelected(element);
177177
}
178178

179-
private static void assertClickingPreservesCurrentlySelectedStatus(WebElement element) {
179+
private void assertClickingPreservesCurrentlySelectedStatus(WebElement element) {
180180
boolean currentSelectedStatus = element.isSelected();
181181
element.click();
182182
assertSelected(element, currentSelectedStatus);
@@ -190,7 +190,7 @@ private static String describe(WebElement element) {
190190
return element.getAttribute("id");
191191
}
192192

193-
private static void assertCanToggle(WebElement element) {
193+
private void assertCanToggle(WebElement element) {
194194
final boolean originalState = element.isSelected();
195195

196196
assertSelected(element, originalState);
@@ -199,7 +199,7 @@ private static void assertCanToggle(WebElement element) {
199199
assertTogglingSwapsSelectedStateFrom(element, !originalState);
200200
}
201201

202-
private static void assertTogglingSwapsSelectedStateFrom(WebElement element, boolean originalState) {
202+
private void assertTogglingSwapsSelectedStateFrom(WebElement element, boolean originalState) {
203203
element.click();
204204
boolean isNowSelected = element.isSelected();
205205
assertThat(

java/client/test/org/openqa/selenium/qtwebkit/nativetests/TextHandlingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public void testShouldBeAbleToSetMoreThanOneLineOfTextInATextArea() {
136136
WebElement textarea = driver.findElement(By.id("emptytext"));
137137
textarea.clear();
138138

139-
waitFor(WaitingConditions.elementTextToEqual(textarea, ""));
139+
wait.until(WaitingConditions.elementTextToEqual(textarea, ""));
140140

141141
String expectedText = "i like cheese" + newLine + newLine + "it's really nice";
142142

0 commit comments

Comments
 (0)