[英]Why doesn't my basic program through Selenium and Java works?
I used the code below to login into amazon website and it works but somehow its not identifying the element for password. 我使用下面的代码登录到亚马逊网站,它可以工作,但是以某种方式无法识别密码元素。
driver.get("accounts@gmail.com");
WebElement signIn = driver.findElement(By.id("Email"));
signIn.sendKeys("XXX@gmail.com");
signIn.submit();
WebElement pwd = driver.findElement(By.id("Passwd"));
pwd.sendKeys("password");
pwd.submit();
Within driver.get()
line instead of your EmailID
you need to pass the relevant amazon url as an example https://www.amazon.com/
. 在driver.get()
行中,而不是您的EmailID
您需要传递相关的亚马逊URL作为示例https://www.amazon.com/
。
So instead of: 所以代替:
driver.get("accounts@gmail.com");
You would like to: 你想要...吗:
driver.get("https://www.amazon.com/");
driver.get(<URL>)
. 要运行代码,请将有效的URL放入语句driver.get(<URL>)
。 For Example: driver.get("www.amazon.com)
. This will successfully open the Amazon site in whichever browser your driver is trying to open 例如: driver.get("www.amazon.com)
。这将成功在驱动程序尝试打开的浏览器中打开Amazon网站。 2.You have mentioned in a comment as "code is failing for sending value to password field". 2.您在注释中提到“代码无法将值发送到密码字段”。 I would suggest you to write an Xpath for it, if the id locator isn't working. 如果ID定位器不起作用,我建议您为此编写一个Xpath。
However, if you want the people to help you out more, please place the HTML code of your page and also error received, it will be easy to debug and also to provide accurate answer. 但是,如果您想让人们更多地帮助您,请放置页面的HTML代码以及收到的错误,这将很容易调试并提供准确的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.