Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • An element could not be located on the page using the given search parameters

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 8.84k
    Comment on it

    I tried to run the below code

    public class TestSelendroidApp {
    public static AndroidDriver driver;
        public static void main(String[] args) throws MalformedURLException, InterruptedException {
             File app = new File("E:\software\selendroid-test-app-0.11.0.apk");
             DesiredCapabilities capabilities = new DesiredCapabilities();
             DesiredCapabilities cap = new DesiredCapabilities();
             cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
             capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Appium");
             capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
             capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "4.2.2");
             capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android");
             capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
             driver = new AndroidDriver(new URL(""), capabilities);

    After running this code I am getting the following error:

    Exception in thread "main" 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) Command duration or timeout: 565 milliseconds For documentation on this error, please visit: Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33' System info: host: 'xxxxxxxxxxxxx', ip: 'xxxxxxxxxxxxxxxxxx', 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0' Driver info: Capabilities [{app=E:\software\selendroid-test-app-0.11.0.apk, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=42033d5fcacf4100, platform=LINUX, desired={app=E:\software\selendroid-test-app-0.11.0.apk, platformVersion=4.2.2, automationName=Appium, platformName=Android, deviceName=Android}, platformVersion=4.2.2, webStorageEnabled=false, locationContextEnabled=false, automationName=Appium, browserName=Android, takesScreenshot=true, javascriptEnabled=true, platformName=Android}] Session ID: 72adde8a-db33-4f2b-a26e-90f1640cb7c4 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance( at sun.reflect.DelegatingConstructorAccessorImpl.newInstance( at java.lang.reflect.Constructor.newInstance( at org.openqa.selenium.remote.ErrorHandler.createThrowable( at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed( at org.openqa.selenium.remote.RemoteWebDriver.execute( at io.appium.java_client.AppiumDriver.execute( at org.openqa.selenium.remote.RemoteWebDriver.findElement( at at TestSelendroidApp.main(

    Solution for the above error is:

    The above error comes when the condition is false and the element could not be located with the given search criteria but still we are trying to perform some action over the webelement. For eg: in the above highlighted line of code, we are trying to click the checkbox which is not checked(ie trying to click the unchecked checkbox) but the checkbox is in checked state, so the unchecked checkbox could not be located and we got the above error. In the above code if we pass ''true' as an argument in checked() method then the webbelement could be located.


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: