可以手动登录,但是使用salenium webdriver显示无效的凭证,如何处理? [英] manually able to log in but with salenium webdriver its showing invalid credentials,how to handle this?

查看:147
本文介绍了可以手动登录,但是使用salenium webdriver显示无效的凭证,如何处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有Java的Selenium Webdriver来自动化基于angularJS的应用程序.我可以手动登录到应用程序,但可以自动显示无效的凭据.我检查了凭证,它们是相同的.我尝试了两种位置策略,即CSS选择器和Xpath结果是相同的.

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");//用户名

/*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();

推荐答案

Css选择器正在复制,并且正在将凭据发送给admin而不是普通用户.由于凭据输入时的登录ur是相同的,因此很难找到.编辑xpath.

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.

这篇关于可以手动登录,但是使用salenium webdriver显示无效的凭证,如何处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆