【发布时间】:2021-11-30 06:30:47
【问题描述】:
地址和帐单地址有 2 个字段,这两个字段都会抛出建议。
如果我对帐单地址代码有效的地址代码发表评论,我的代码就可以了。 如果我对帐单地址代码发表评论,则地址代码有效。 但是当我注释掉你所知道的一切时无法运行它?代码如下。
//adding address and select from the suggestion bar here I'm selecting with ID
driver.findElement(By.id("entityAddress_0")).sendKeys("Khalifa city sector 13");
driver.manage().timeouts().implicitlyWait(2000, TimeUnit.MILLISECONDS);
List <WebElement> suggestion = driver.findElements(By.className("pac-item")); //here I print all the value which are coming
//here I'm using for each loop and print the value so we can see all the value which appeared in suggestions
for (WebElement suggest : suggestion) {
if(suggest.getText().equalsIgnoreCase("Sector 13Khalifa City - Abu Dhabi - United Arab Emirates")) {
suggest.click();
break;
}
Thread.sleep(1000);
//now adding the billing address
driver.findElement(By.id("entityAddress_01")).sendKeys("Khalifa city sector 13");
driver.manage().timeouts().implicitlyWait(2000, TimeUnit.MILLISECONDS);
List <WebElement> suggestions =driver.findElements(By.className("pac-item-query"));
for (WebElement suggests : suggestions) {
//System.out.println(suggests.getText());
if(suggests.getText().equalsIgnoreCase("Khalifa city"));
suggests.click();
}
}}}
【问题讨论】:
-
请始终描述当前和期望的行为,并包括堆栈跟踪和页面源代码或 url。
-
在端口 45380 上启动 ChromeDriver 94.0.4606.61 (418b78f5838ed0b1c69bb4e51ea0252171854915-refs/branch-heads/4606@{#1204}) 只允许本地连接。请参阅chromedriver.chromium.org/security-considerations 获取有关确保 ChromeDriver 安全的建议。 ChromeDriver 已成功启动。 2021 年 10 月 13 日上午 11:50:46 org.openqa.selenium.remote.ProtocolHandshake createSession INFO:检测到的方言:W3C 当我注释掉上面的代码时代码不起作用,然后它就起作用了。当我想完成流程并注释掉代码时,它就会停止。
-
如果某个答案对您有帮助,请选择它。
标签: java selenium automation