在chrome中使用selenium webdriver时,提交按钮正常工作,单击时表单中的所有数据都会正确显示。
但是当我使用IE时,按钮会暂时重定向到所需的页面,然后重定向到登录页面。
我做了一些工作并清除了chrome浏览器的缓存,然后尝试提交表单,导航到登录页面,所以我认为这是IE的问题, 但我不知道如何照顾它。
WebDriver driver;
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(InternetExplorerDriver.UNEXPECTED_ALERT_BEHAVIOR, UnexpectedAlertBehaviour.IGNORE);
cap.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
cap.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
driver = new InternetExplorerDriver(cap);
driver.get("my url");
WebElement username, password, Iagree;
username = driver.findElements(By.name("USER")).get(0);
username.clear();
username.sendKeys("user");
password = driver.findElements(By.name("PASSWORD")).get(0);
password.clear();
password.sendKeys("pass");
Iagree = driver.findElements(By.xpath("login")).get(0);
Iagree.click();
System.out.println("Login Completed!");
Thread.sleep(5000);
driver.findElement(By.xpath("//*[@id='userid']")).clear();
driver.findElement(By.xpath("//*[@id='userid']")).sendKeys("abc");
driver.findElement(By.xpath("//*[@id='xxxx']")).sendKeys("ert");
driver.findElement(By.xpath("//*[@id='xxxx']")).clear();
driver.findElement(By.xpath("//*[@id='xxxx']")).sendKeys("xxxx");
// after many more fields, there's a submit button.
WebElement element=driver.findElement(By.xpath("//*[@id='Submit']"));
element.click();
/*JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript("return document.readyState").equals("complete");*/
WebDriverWait wait = new WebDriverWait(driver, 10000);
wait.until( new Predicate<WebDriver>() { public boolean apply(WebDriver driver) { return ((JavascriptExecutor)driver).executeScript("return document.readyState").equals("complete"); } } );
/*JavascriptExecutor jse=(JavascriptExecutor)driver;
jse.executeScript("arguments[0].click();", element);
*/
/*Actions builder = new Actions(driver);
builder.moveToElement(element).perform();
builder.click().perform();*/
所以这适用于Chrome但不适用于IE11
请帮助。
答案 0 :(得分:0)
你能提供你的代码吗?似乎请求发布问题。请遵循以下规则:
?
并刷新网页。[结果看起来像是你被绊倒] type='button'
或return false;
希望这会对你有所帮助......