appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.22k stars 758 forks source link

Appium v1.8.1 explicit wait is not working - This issue appeared after updating appium #964

Closed bkmork closed 6 years ago

bkmork commented 6 years ago
I have used following code for explicit wait.

            WebDriverWait wait=new WebDriverWait(driver, 60);
            wait.until(ExpectedConditions.visibilityOf(element));
            element.click();
ERROR | 2018-07-02 18:10:51 | [main] ObjectHelper.ObjectActions (ObjectActions.java:125) - Entering values has issueAn element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 78 milliseconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System info: host: 'MSI-WST-006', ip: ' ', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_141' Driver info: io.appium.java_client.android.AndroidDriver
saikrishna321 commented 6 years ago

@bkmork Please provide full server logs, no one can help you with the information provided.

bkmork commented 6 years ago

@saikrishna321 , Sorry for the delay.

Please find the following code and logs.

public static AndroidElement readObject(String Key) throws Exception { WebDriverWait wait=new WebDriverWait(driver, 30); String locators[] = ExcelReader.readAndroidLocatorFromExcel(Key); // System.out.println(Arrays.toString(locators)); if (locators[0].equalsIgnoreCase("classname")) {

        wait.until(ExpectedConditions.visibilityOfElementLocated((By) driver.findElementByClassName(locators[1])));
         return (AndroidElement)  driver.findElementByClassName(locators[1]);
    } else if (locators[0].equalsIgnoreCase("xpath")) {

        wait.until(ExpectedConditions.visibilityOfElementLocated((By) driver.findElementByXPath(locators[1])));
        return (AndroidElement)  driver.findElementByXPath(locators[1]);
    } else if (locators[0].equalsIgnoreCase("name")) {

         wait.until(ExpectedConditions.visibilityOfElementLocated((By) driver.findElementByName(locators[1])));
         return(AndroidElement) driver.findElement(By.name(locators[1]));
    } else if (locators[0].equalsIgnoreCase("id")) {

         wait.until(ExpectedConditions.visibilityOfElementLocated((By) driver.findElementById(locators[1])));
         return (AndroidElement) driver.findElementById(locators[1]);
    } else if (locators[0].equalsIgnoreCase("contentdesc")) {

        wait.until(ExpectedConditions.visibilityOfElementLocated((By) driver.findElementsByAccessibilityId(locators[1])));
        return (AndroidElement) driver.findElementsByAccessibilityId(locators[1]);
    }

    // System.out.println(locators);
    return null;

}

-------< Appium Logs >------ [Appium] Welcome to Appium v1.8.1 [Appium] Non-default server args: [Appium] address: 127.0.0.1 [Appium] Appium REST http interface listener started on 127.0.0.1:4723

[UiAutomator] Starting UiAutomator [UiAutomator] Moving to state 'starting' [UiAutomator] Parsing uiautomator jar [UiAutomator] Found jar name: 'AppiumBootstrap.jar' [ADB] Running 'D:\android-sdks\platform-tools\adb.exe -P 5037 -s BL15C2AquaX77S000009 push C\:\Users\balakrishna\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-android-bootstrap\bootstrap\bin\AppiumBootstrap.jar /data/local/tmp/' [ADB] Attempting to kill all uiautomator processes [ADB] Getting all processes with uiautomator [ADB] Running 'D:\android-sdks\platform-tools\adb.exe -P 5037 -s BL15C2AquaX77S000009 shell ps' [ADB] Attempting to kill process 19683 [ADB] Running 'D:\android-sdks\platform-tools\adb.exe -P 5037 -s BL15C2AquaX77S000009 shell kill -0 19683' [ADB] Running 'D:\android-sdks\platform-tools\adb.exe -P 5037 -s BL15C2AquaX77S000009 shell kill 19683' [UiAutomator] UiAutomator exited unexpectedly with code 4294967183, signal null [UiAutomator] Moving to state 'stopped' [AndroidDriver] Shutting down Android driver [ADB] Running 'D:\android-sdks\platform-tools\adb.exe -P 5037 -s BL15C2AquaX77S000009 shell am force-stop com.meeier.yx.android' [ADB] Running 'D:\android-sdks\platform-tools\adb.exe -P 5037 -s BL15C2AquaX77S000009 shell kill 19683' [Appium] Closing session, cause was 'UiAUtomator shut down unexpectedly' [Appium] Removing session 20005fca-4e29-45c9-8cee-bea920b9e36b from our master session list [ADB] Running 'D:\android-sdks\platform-tools\adb.exe -P 5037 -s BL15C2AquaX77S000009 shell kill 19683' [ADB] Pressing the HOME button [ADB] Running 'D:\android-sdks\platform-tools\adb.exe -P 5037 -s BL15C2AquaX77S000009 shell input keyevent 3' [UiAutomator] Starting UIAutomator [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","BL15C2AquaX77S000009","shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.meeier.yx.android","-e","disableAndroidWatchers",false,"-e","acceptSslCerts",false] [AndroidBootstrap] Cannot shut down Android bootstrap; it has already shut down [Logcat] Stopping logcat capture [ADB] Running 'D:\android-sdks\platform-tools\adb.exe -P 5037 -s BL15C2AquaX77S000009 shell am force-stop io.appium.unlock' [UiAutomator] Moving to state 'online' [AndroidBootstrap] Android bootstrap socket is now connected [ADB] Running 'D:\android-sdks\platform-tools\adb.exe -P 5037 -s BL15C2AquaX77S000009 shell dumpsys window' [AndroidBootstrap] [BOOTSTRAP LOG] [debug] json loading complete. [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers. [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected [AndroidDriver] Screen already unlocked, doing nothing [ADB] Device API level: 24 [ADB] Running 'D:\android-sdks\platform-tools\adb.exe -P 5037 -s BL15C2AquaX77S000009 shell am start -W -n com.meeier.yx.android/com.meeier.yx.android.meeierceyxActivity -S' [AndroidDriver] Not cleaning generated files. Add clearSystemFiles capability if wanted. [Appium] New AndroidDriver session created successfully, session b9a04cd2-2cb5-442d-ab55-3ac362b828ec added to master session list [BaseDriver] Event 'newSessionStarted' logged at 1530783934437 (15:15:34 GMT+0530 (India Standard Time)) [MJSONWP] Responding to client with driver.createSession() result: {"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"D:\Automated-Testcase\OxygenSmokeTestingSuite\Apps\pdx_UAT_oxandroid.apk","appPackage":"com.meeier.yx.android","appActivity":"com.meeier.yx.android.meeierceyxActivity","newCommandTimeout":500,"platformVersion":"7","platformName":"Android","deviceName":"ZY3222CZ84","fullReset":false},"app":"D:\Automated-Testcase\OxygenSmokeTestingSuite\Apps\pdx_UAT_oxandroid.apk","appPackage":"com.meeier.yx.android","appActivity":"com.meeier.yx.android.meeierceyxActivity","newCommandTimeout":500,"platformVersion":"7.0","platformName":"Android","deviceName":"BL15C2AquaX77S000009","fullReset":false,"deviceUDID":"BL15C2AquaX77S000009","deviceScreenSize":"480x854","deviceModel":"INTEX AQUA STYLE 3","deviceManufacturer":"INTEX"} [HTTP] <-- POST /wd/hub/session 200 56708 ms - 1008 [HTTP] [HTTP] --> POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/timeouts [HTTP] {"type":"implicit","ms":20000} [W3C] Bad parameters: BadParametersError: Parameters were incorrect. We wanted "W3C protocol expects any of script, pageLoad or implicit to be set" and you sent {"type":"implicit","ms":20000} [HTTP] <-- POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/timeouts 400 2 ms - 6620 [HTTP] [HTTP] --> POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/execute [HTTP] {"script":"return navigator.userAgent;","args":[]} [W3C] Calling AppiumDriver.execute() with args: ["return navigator.userAgent;",[],"b9a04cd2-2cb5-442d-ab55-3ac362b828ec"] [HTTP] <-- POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/execute 501 3 ms - 112 [HTTP] [HTTP] --> POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/execute [HTTP] {"script":"return navigator.userAgent;","args":[]} [W3C] Calling AppiumDriver.execute() with args: ["return navigator.userAgent;",[],"b9a04cd2-2cb5-442d-ab55-3ac362b828ec"] [HTTP] <-- POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/execute 501 3 ms - 112 [HTTP] [HTTP] --> POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/element [HTTP] {"using":"xpath","value":"//android.widget.Button[@content-desc='Navigate to next screen.' and @text='Skip']"} [W3C] Calling AppiumDriver.findElement() with args: ["xpath","//android.widget.Button[@content-desc='Navigate to next screen.' and @text='Skip']","b9a04cd2-2cb5-442d-ab55-3ac362b828ec"] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [BaseDriver] Waiting up to 0 ms for condition [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.Button[@content-desc='Navigate to next screen.' and @text='Skip']","context":"","multiple":false}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.Button[@content-desc='Navigate to next screen.' and @text='Skip']","context":"","multiple":false}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//android.widget.Button[@content-desc='Navigate to next screen.' and @text='Skip']' using 'XPATH' with the contextId: '' multiple: false [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying. [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//android.widget.Button[@content-desc='Navigate to next screen.' and @text='Skip']' using 'XPATH' with the contextId: '' multiple: false [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"} [AndroidBootstrap] Received command result from bootstrap [MJSONWP] Matched JSONWP error code 7 to NoSuchElementError [HTTP] <-- POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/element 500 198 ms - 164 [HTTP] [HTTP] --> POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/execute [HTTP] {"script":"return navigator.userAgent;","args":[]} [W3C] Calling AppiumDriver.execute() with args: ["return navigator.userAgent;",[],"b9a04cd2-2cb5-442d-ab55-3ac362b828ec"] [HTTP] <-- POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/execute 501 1 ms - 112 [HTTP] [HTTP] --> POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/execute [HTTP] {"script":"return navigator.userAgent;","args":[]} [W3C] Calling AppiumDriver.execute() with args: ["return navigator.userAgent;",[],"b9a04cd2-2cb5-442d-ab55-3ac362b828ec"] [HTTP] <-- POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/execute 501 2 ms - 112 [HTTP] [HTTP] --> POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/element [HTTP] {"using":"xpath","value":"//android.widget.Button[@index='0']"} [W3C] Calling AppiumDriver.findElement() with args: ["xpath","//android.widget.Button[@index='0']","b9a04cd2-2cb5-442d-ab55-3ac362b828ec"] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [BaseDriver] Waiting up to 0 ms for condition [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.Button[@index='0']","context":"","multiple":false}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.Button[@index='0']","context":"","multiple":false}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//android.widget.Button[@index='0']' using 'XPATH' with the contextId: '' multiple: false [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying. [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//android.widget.Button[@index='0']' using 'XPATH' with the contextId: '' multiple: false [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"} [AndroidBootstrap] Received command result from bootstrap [MJSONWP] Matched JSONWP error code 7 to NoSuchElementError [HTTP] <-- POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/element 500 1408 ms - 164 [HTTP] [HTTP] --> POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/element [HTTP] {"using":"xpath","value":"//android.widget.EditText[contains(@resource-id, 'id/titanium_ui_edittext') and @instance='0']"} [W3C] Calling AppiumDriver.findElement() with args: ["xpath","//android.widget.EditText[contains(@resource-id, 'id/titanium_ui_edittext') and @instance='0']","b9a04cd2-2cb5-442d-ab55-3ac362b828ec"] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [BaseDriver] Waiting up to 0 ms for condition [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.EditText[contains(@resource-id, 'id/titanium_ui_edittext') and @instance='0']","context":"","multiple":false}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.EditText[contains(@resource-id, 'id/titanium_ui_edittext') and @instance='0']","context":"","multiple":false}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//android.widget.EditText[contains(@resource-id, 'id/titanium_ui_edittext') and @instance='0']' using 'XPATH' with the contextId: '' multiple: false [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying. [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//android.widget.EditText[contains(@resource-id, 'id/titanium_ui_edittext') and @instance='0']' using 'XPATH' with the contextId: '' multiple: false [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"} [AndroidBootstrap] Received command result from bootstrap [MJSONWP] Matched JSONWP error code 7 to NoSuchElementError [HTTP] <-- POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/element 500 496 ms - 164 [HTTP] [HTTP] --> POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/appium/device/hide_keyboard [HTTP] {} [W3C] Calling AppiumDriver.hideKeyboard() with args: [null,null,null,null,"b9a04cd2-2cb5-442d-ab55-3ac362b828ec"] [ADB] Running 'D:\android-sdks\platform-tools\adb.exe -P 5037 -s BL15C2AquaX77S000009 shell dumpsys input_method' [MJSONWP] Encountered internal error running command: Error: Soft keyboard not present, cannot hide keyboard [MJSONWP] at AndroidDriver.callee$0$0$ (C:\Users\balakrishna\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\commands\general.js:54:11) [MJSONWP] at tryCatch (C:\Users\balakrishna\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40) [MJSONWP] at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\balakrishna\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22) [MJSONWP] at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\balakrishna\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21) [MJSONWP] at GeneratorFunctionPrototype.invoke (C:\Users\balakrishna\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37) [MJSONWP] at [HTTP] <-- POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/appium/device/hide_keyboard 500 1422 ms - 218 [HTTP] [HTTP] --> POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/execute [HTTP] {"script":"return navigator.userAgent;","args":[]} [W3C] Calling AppiumDriver.execute() with args: ["return navigator.userAgent;",[],"b9a04cd2-2cb5-442d-ab55-3ac362b828ec"] [HTTP] <-- POST /wd/hub/session/b9a04cd2-2cb5-442d-ab55-3ac362b828ec/execute 501 2 ms - 112

SrinivasanTarget commented 6 years ago

[MJSONWP] Encountered internal error running command: Error: Soft keyboard not present, cannot hide keyboard

@bkmork

SrinivasanTarget commented 6 years ago

Try UIA2 mode

bkmork commented 6 years ago

@SrinivasanTarget , @saikrishna321 . Thanks for the support.

The issue was with the code and now its working fine. Following is the working code

public static AndroidElement readObject(String Key) throws Exception { WebDriverWait wait=new WebDriverWait(driver, 30); String locators[] = ExcelReader.readAndroidLocatorFromExcel(Key); // System.out.println(Arrays.toString(locators)); if (locators[0].equalsIgnoreCase("classname")) {

        wait.until(ExpectedConditions.visibilityOfElementLocated(By.className(locators[1])));
         return (AndroidElement)  driver.findElementByClassName(locators[1]);
    } else if (locators[0].equalsIgnoreCase("xpath")) {

        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(locators[1])));
        return (AndroidElement)  driver.findElementByXPath(locators[1]);
    } else if (locators[0].equalsIgnoreCase("name")) {

         wait.until(ExpectedConditions.visibilityOfElementLocated(By.name(locators[1])));
         return(AndroidElement) driver.findElement(By.name(locators[1]));
    } else if (locators[0].equalsIgnoreCase("id")) {

         wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(locators[1])));
         return (AndroidElement) driver.findElementById(locators[1]);
    } else if (locators[0].equalsIgnoreCase("contentdesc")) {

        wait.until(ExpectedConditions.visibilityOfElementLocated((By.name(locators[1]))));
        return (AndroidElement) driver.findElementsByAccessibilityId(locators[1]);

    }

    // System.out.println(locators);
    return null;

}