1

I'm working in appium. It couldn't get automate a enter password field. Only issue is enter password field login button click is working fine .I tried by using with xpath, cssselector and also className, But not get to autoamte. code for enter password then click on login button

public Login invalidLogin() {



        MobileElement element = (MobileElement) driver.findElement(By.xpath("//*[@id=\'main\']/div[1]/form/div[1]/div/label/input"));
        element.sendKeys("9400693133");
        MobileElement element1 = (MobileElement) driver.findElement(By.xpath("//*[@id=\'main\']/div[2]/div[1]"));
        element1.click();



   WebDriverWait waitElement = new WebDriverWait(driver, 20);
    waitElement.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@type=‘password’]")));

            MobileElement element2= (MobileElement) driver.findElement(By.xpath("//input[@type=‘password’]"));
            element2.sendKeys("abcd");

   waitElement.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@ng-click='sentloginrequest(login_passwd)']")));

            MobileElement element3= (MobileElement) driver.findElement(By.xpath("//div[@ng-click='sentloginrequest(login_passwd)']"));
            element3.click();

    return new Login(driver);

Error:

 org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: By.xpath: //input[@type=‘password’] (tried for 20 second(s) with 500 MILLISECONDS interval)
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'

And I tried this too put xpath("//input[@ng-model=‘login_passwd’]") Error:

org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: By.xpath: //input[@ng-model=‘login_passwd’] (tried for 20 second(s) with 500 MILLISECONDS interval)
0

Looking at the code looks like your app is build in Angular JS.

can you try following code.

WebDriverWait waitElement = new WebDriverWait(driver, 20);
waitElement.until(ExpectedConditions.elementToBeClickable(By.xpath(“//input[@type=‘password’]”)));

MobileElement element4= (MobileElement) driver.findElement(By.xpath(“//input[@type=‘password’]”));
element4.sendKeys(“1233”);

waitElement.until(ExpectedConditions.elementToBeClickable(By.xpath(“//div[@ng-click='sentloginrequest(login_passwd)']”)));

MobileElement element4= (MobileElement) driver.findElement(By.xpath("//div[@ng-click='sentloginrequest(login_passwd)']"));
element4.click();
  • org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@ng-click='sentloginrequest(login_passwd)']"} – user24314 Mar 22 '17 at 11:53
  • I want to both enter pasword and click login button. I couldn't get to autoamte till now – user24314 Mar 22 '17 at 12:03
  • @comrade updated answer try adding wait before performing actions on element – Jeevan Bhushetty Mar 22 '17 at 12:33
  • I had edited please check Login click button is working fine and only issue with enter password field – user24314 Mar 23 '17 at 4:28
  • This will work fine xpath("//input[@maxlength='4']") . THanks for the support – user24314 Mar 23 '17 at 5:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy