问题
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