|
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 | | - |
17 | 1 | package io.appium.java_client.ios; |
18 | 2 |
|
| 3 | +import static org.hamcrest.core.Is.is; |
| 4 | +import static org.hamcrest.core.IsNot.not; |
19 | 5 | 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; |
21 | 9 |
|
| 10 | +import org.junit.FixMethodOrder; |
22 | 11 | 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; |
23 | 19 |
|
24 | | -public class IOSElementTest extends AppIOSTest { |
| 20 | +@FixMethodOrder(MethodSorters.NAME_ASCENDING) |
| 21 | +public class IOSElementTest extends UICatalogIOSTest { |
25 | 22 |
|
26 | 23 | @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))); |
29 | 27 | } |
30 | 28 |
|
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); |
36 | 34 |
|
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); |
39 | 45 | slider.setValue("0%"); |
40 | 46 | assertEquals("0%", slider.getAttribute("value")); |
41 | 47 | } |
|
0 commit comments