Skip to content

Commit 6f69389

Browse files
TikhomirovSergeyTikhomirovSergey
authored andcommitted
IOSElement test was improved
1 parent 8ccf24b commit 6f69389

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

src/test/java/io/appium/java_client/ios/IOSElementTest.java

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,47 @@
1-
/*
2-
* Licensed under the Apache License, Version 2.0 (the "License");
3-
* you may not use this file except in compliance with the License.
4-
* See the NOTICE file distributed with this work for additional
5-
* information regarding copyright ownership.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
171
package io.appium.java_client.ios;
182

3+
import static org.hamcrest.core.Is.is;
4+
import static org.hamcrest.core.IsNot.not;
195
import static org.junit.Assert.assertEquals;
20-
import static org.junit.Assert.assertNotEquals;
6+
import static org.junit.Assert.assertThat;
7+
8+
import com.google.common.base.Function;
219

10+
import org.junit.FixMethodOrder;
2211
import org.junit.Test;
12+
import org.junit.runners.MethodSorters;
13+
import org.openqa.selenium.By;
14+
import org.openqa.selenium.WebDriver;
15+
import org.openqa.selenium.WebElement;
16+
import org.openqa.selenium.support.ui.WebDriverWait;
17+
18+
import java.util.List;
2319

24-
public class IOSElementTest extends AppIOSTest {
20+
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
21+
public class IOSElementTest extends UICatalogIOSTest {
2522

2623
@Test public void findByAccessibilityIdTest() {
27-
assertNotEquals(driver.findElementsByClassName("UIAWindow").get(1)
28-
.findElementsByAccessibilityId("ComputeSumButton").size(), 0);
24+
assertThat((driver.findElementsByClassName("UIAWindow").get(1))
25+
.findElementsByAccessibilityId("Sliders").size(),
26+
not(is(0)));
2927
}
3028

31-
@Test public void findByByIosUIAutomationTest() {
32-
assertNotEquals((driver.findElementsByClassName("UIAWindow")
33-
.get(1))
34-
.findElementByIosUIAutomation(".elements().withName(\"Answer\")").getText(), null);
35-
}
29+
@Test public void setValueTest() {
30+
driver.findElementsByClassName("UIAWindow").get(1)
31+
.findElementByAccessibilityId("Sliders").click();
32+
33+
WebDriverWait wait = new WebDriverWait(driver, 20);
3634

37-
@Test public void setValuerTest() {
38-
IOSElement slider = driver.findElementByClassName("UIASlider");
35+
IOSElement slider = (IOSElement) wait.until(new Function<WebDriver, List<WebElement>>() {
36+
@Override
37+
public List<WebElement> apply(WebDriver input) {
38+
List<WebElement> result = input.findElements(By.className("UIASlider"));
39+
if (result.size() == 0) {
40+
return null;
41+
}
42+
return result;
43+
}
44+
}).get(1);
3945
slider.setValue("0%");
4046
assertEquals("0%", slider.getAttribute("value"));
4147
}

src/test/java/io/appium/java_client/pagefactory_tests/IOSPageFactoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323

2424
import io.appium.java_client.MobileElement;
2525
import io.appium.java_client.TouchableElement;
26-
import io.appium.java_client.ios.IOSElement;
2726

2827
import io.appium.java_client.ios.AppIOSTest;
28+
import io.appium.java_client.ios.IOSElement;
2929
import io.appium.java_client.pagefactory.AndroidFindBy;
3030
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
3131
import io.appium.java_client.pagefactory.HowToUseLocators;

0 commit comments

Comments
 (0)