提问人:Vinod Sidiginamale 提问时间:6/8/2017 最后编辑:Vinod Sidiginamale 更新时间:6/9/2017 访问量:470
Selenium 按钮提交/单击未从 chrome Web 驱动程序重定向到成功页面
Selenium button submit /click is not redirecting to success page from chrome web driver
问:
我从一个页面导航到另一个页面时遇到了 Selenium 的问题。
下面是代码。如果我单击以下元素,jQuery图像将打开,直到加载下一页。但它本身并没有导航到下一页。图像继续旋转,窗口将关闭它。为什么?
我得到一个NoSuchElementFoundException
Chrome版本 : 58.0.3029.110
driver.findElement(By.name("continue")).click();
@Test
public void executeLoginApp() throws InterruptedException {
driver.navigate()
.to("url with login application");
WebElement userName = driver.findElement(By.id("uname"));
WebElement pwd = driver.findElement(By.id("passwd"));
userName.sendKeys("test");
pwd.sendKeys("test");
Thread.sleep(2000);
javaScriptExecutor.executeScript("window.scrollTo(0, document.body.scrollHeight)");
Thread.sleep(2000);
//driver.findElement(By.xpath("//input[@name='continue']")).click();
//Thread.sleep(1000);
//driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
driver.findElement(By.name("continue")).click();
//signOn.click();
callYourInformation();
}
private void callYourInformation() {
/*try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
WebDriverWait wait = new WebDriverWait(driver, 10);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
String previousURL = driver.getCurrentUrl();
ExpectedCondition e = new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return (d.getCurrentUrl() != previousURL);
}};
wait.until(e);}*/
// currentURL = driver.getCurrentUrl();
if (driver.getCurrentUrl().contains("yourinfo")) {
// testing yourinfo page
WebElement emailAddress = driver.findElement(By.id("emailAddress"));
emailAddress.clear();
emailAddress.sendKeys("[email protected]");
WebElement addressLine1 = driver.findElement(By.id("addressLine1"));
addressLine1.clear();
addressLine1.sendKeys("New york");
WebElement grossAnnualIncome = driver.findElement(By.id("grossAnnualIncome"));
grossAnnualIncome.sendKeys(String.valueOf(6000));
WebElement submit = driver.findElement(By.id("submitApplication"));
submit.click();
driver.findElement(By.id("Continue")).click();
}
else{
do other logic.
}
我尝试了所有方法,但没有运气。注释行是我的尝试,但它们都没有重定向到该页面。
答: 暂无答案
评论