manually able to log in but with salenium webdriver its showing invalid credentials,how to handle this?

不问归期 提交于 2019-12-08 12:48:07

问题


i am using Selenium webdriver with java to automate an angularJS based app. Manually i am able to log in to the application but in automation its showing invalid credentials. I checked with credential, they are same. I tried two location strategies Css selector and Xpath results are same.

/*driver.findElement(By.cssSelector("#username")).sendKeys("9813555555");//username

    driver.findElement(By.cssSelector("#password")).sendKeys("9813555555");//password
      driver.findElement(By.cssSelector(".btn.btn-primary.login-btn")).click();//login
*/    

      driver.findElement(By.xpath("html/body/div[1]/div/div/div/div/div/div/div/form/div[1]/div/div/input")).sendKeys("98135555555");

      driver.findElement(By.xpath("html/body/div[1]/div/div/div/div/div/div/div/form/div[2]/div/div/input")).sendKeys("98135555555");

      driver.findElement(By.xpath("html/body/div[1]/div/div/div/div/div/div/div/form/div[3]/div[2]/button")).click();

回答1:


the Css selector was duplicating and it was sending credential to admin instead of normal user .it was difficult to find as login ur at credential input was same.handled by editing xpath.



来源:https://stackoverflow.com/questions/38241487/manually-able-to-log-in-but-with-salenium-webdriver-its-showing-invalid-credenti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!