OPT*_*MUS 4 java selenium webdriver selenium-webdriver
我按下取消按钮比根据我的代码检查一些文本.在Chrome和Firefox中它工作正常但在IE中需要时间在警报框上执行操作,但代码移动到下一行.
所以我想要一些代码停止,直到操作在警告框中执行,然后进入下一步.我正在使用硒进行自动化测试.
请找一段代码:
Alert al = driver.switchTo().alert();
al.accept();
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//*[@id='content-body-full']/p[1]")));
assertEquals("Your cancellation request has been successfully executed.",driver.findElement(By.xpath(".//*[@id='content-body-full']/p[1]")).getText().toString());
Run Code Online (Sandbox Code Playgroud)
Erk*_* M. 12
您希望等到警报出现后再切换到它,类似于第3行.参考.
编辑:尝试:
new WebDriverWait(driver, 60)
.ignoring(NoAlertPresentException.class)
.until(ExpectedConditions.alertIsPresent());
Alert al = driver.switchTo().alert();
al.accept();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6773 次 |
| 最近记录: |