Я пытаюсь установить настройку тестирования Appium с Java для тестирования на Android. Чтобы проверить мои элементы, я использую AndroidUiAutomator. В UI Automator Viewer я вижу, что распространилась метка доступности (см. Прикрепленное изображение). Когда я использую findElement (By.name | By.AccessibilityId | и т. Д., Он обычно просто истекает время, и консоль терминала сервера Appium должна быть перезапущена для запуска теста. Я получаю аналогичные результаты с помощью FindByXPath. Я пробовал ждать, используя тайм-аут и waitdriver, чтобы убедитесь, что загружаются элементы, но это было напрасно я пытался почти все перечисленные в коде нижеAppium не может найти элемент по содержанию-description/accessibilityID
/**
* Created by appium on 12/6/16.
*/
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidElement;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.WebDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.Select;
import java.util.*;
import java.net.URL;
public class FirstTest {
AndroidDriver driver;
@Before
public void setUp() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Android Emulator");
capabilities.setCapability("BROWSER_NAME", "Android");
capabilities.setCapability("app", apkloc);
capabilities.setCapability("VERSION", "5.0.0");
capabilities.setCapability("platformName", "Android");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
// Thread.sleep(100);
//driver.manage().timeouts().implicitlyWait(100000, TimeUnit.SECONDS);
System.out.println("driver1=" + driver);
}
@Test
public void login() throws InterruptedException {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
MobileElement mo = (MobileElement) driver.findElementByAndroidUIAutomator("new UiSelector().text(\"username\")");
WebDriverWait wait = new WebDriverWait(driver, 1000);
System.out.println("driver4=" + driver);
WebElement element = driver.findElement(By.xpath("//EditText[@text='username']"));
WebElement elly = driver.findElementByXPath("//[@id=wutitdo]");
System.out.println("olly-mint: "+elly);
WebElement element2 = driver.findElementByName("password");
//WebElement element3 = driver.findElementByXPath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.view.View[4]");
//WebElement element4 = driver.findElementByName("");
//WebElement element3 = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.view.View[4]")));
// WebElement exp = (WebElement) (new WebDriverWait(driver, 15)).until(ExpectedConditions.presenceOfElementLocated(By.name("Trip")));
System.out.println("dr" + driver);
//element.click();
//WebDriverWait wait = new WebDriverWait(driver, 10);
// element2.click();
Thread.sleep(1000);
//element3.click();
//WebElement current = (new WebDriverWait(driver,100)).until(ExpectedConditions.presenceOfElementLocated(By.name("username")));
//current.sendKeys();
// WebElement dropdown = driver.findElement(By.xpath("//*[@id='wrapper']/table[2]/tbody/tr[24]/td[3]/select[1]"));
//WebElement dropdown = driver.findElement(By.xpath("//*[@id='wrapper']/table[2]/tbody/tr[24]/td[3]/select[1]"));
//Select listbox = new Select(driver.findElement(By.xpath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.view.View[1]/android.view.View[0]")));
//listbox.selectByIndex(0);
//listbox.selectByIndex(3);
//driver.findElement(By.xpath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.view.View[1]/android.view.View[3]")).click();
//Thread.sleep(2000);
//element4.click();
//Thread.sleep(1000);
}
@After
public void tearDown() throws Exception {
System.out.println("driver3=" + driver);
driver.quit();
}
}
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/JPegT.png
что версия Appium вы используете? –
настоящее время я использую 1.6.2 –