小编Shi*_*ppa的帖子

无法使用Appium在Android中的权限对话框中单击"允许"按钮

我无法使用Appium + Java在Android的权限对话框中点击"拒绝"或"允许"按钮.在点击这些按钮之前,是否需要添加任何功能?以下是代码:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "ASUS_Z00LD");
capabilities.setCapability("platformVersion", "6.0");
capabilities.setCapability("app","<AppPath>");
capabilities.setCapability("browserName", "");
AndroidDriver<MobileElement> driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
        Thread.sleep(10000);
driver.findElement(MobileBy.id("permission_allow_button")).click();
Run Code Online (Sandbox Code Playgroud)

以下是Eclipse控制台中的错误:

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Run Code Online (Sandbox Code Playgroud)

以下是Appium日志:

info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"6.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"/Users/Shiva/Documents/workspace/AndroidPractice/APK/****_Android.apk","browserName":"","platformName":"Android","deviceName":"ASUS_Z00LD","platformVersion":"6.0"},"app":"/Users/Shiva/Documents/workspace/AndroidPractice/APK/****_Android.apk","platformName":"Android","deviceName":"FAAZCY127084"},"sessionId":"b64fd5af-3de5-4299-a2d4-1948fc8e883e"}
info: <-- GET /wd/hub/session/b64fd5af-3de5-4299-a2d4-1948fc8e883e 200 1.534 ms - 625 {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"6.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"/Users/Shiva/Documents/workspace/AndroidPractice/APK/****_Android.apk","browserName":"","platformName":"Android","deviceName":"ASUS_Z00LD","platformVersion":"6.0"},"app":"/Users/Shiva/Documents/workspace/AndroidPractice/APK/****_Android.apk","platformName":"Android","deviceName":"FAAZCY127084"},"sessionId":"b64fd5af-3de5-4299-a2d4-1948fc8e883e"}

info: --> POST /wd/hub/session/b64fd5af-3de5-4299-a2d4-1948fc8e883e/element {"using":"id","value":"permission_allow_button"}

info: [debug] Waiting up to …
Run Code Online (Sandbox Code Playgroud)

java selenium android selenium-webdriver appium

8
推荐指数
3
解决办法
4938
查看次数

org.openqa.selenium.ElementNotVisibleException:元素当前不可见,因此可能无法与之交互

我试图在Selenium Web驱动程序脚本下面执行,但是我得到org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with错误几次(并非所有时间).有时在循环第一次迭代中,有时在2次迭代中,有时没有启动循环.它打印所有可用的项目计数正确,但乳清试图点击项目,它显示Element is not currently visible...

public void pickitems() throws Exception  
        {
        Webdriver driver = new firefoxdriver();
        driver.get("http://www.bigbasket.com");
        driver.manage().window().maximize();
            //Selecting Location
        List<WebElement> list = driver.findElement(By.id("ftv-city-popup")).findElements(By.tagName("button"));
        int location = r.nextInt(list.size());
        list.get(location).click();
            //Selection random Category from left panel through list 
        Thread.sleep(30000);
        List<WebElement> xyz = driver.findElement(By.id("uiv2-main-menu")).findElements(By.className("top-category"));
        System.out.println(xyz.size());
        Random r = new Random();
        int category = r.nextInt(xyz.size());
        xyz.get(category).click();


        for (int i = 0; i < 3; i++) {
            Thread.sleep(30000); …
Run Code Online (Sandbox Code Playgroud)

java selenium dom selenium-webdriver

5
推荐指数
2
解决办法
6万
查看次数

标签 统计

java ×2

selenium ×2

selenium-webdriver ×2

android ×1

appium ×1

dom ×1