System.setProperty("webdriver.ie.driver","E:\\zzWS\\Suizhi\\Driver\\IEDriverServer32.exe");
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
WebDriver dr = new InternetExplorerDriver(caps);
dr.get("http://www.suizhi.com");
//*****显示登录div begin*****
JavascriptExecutor js = (JavascriptExecutor) dr;
String myjs="document.getElementsByClassName('login')[0].click();";
js.executeScript(myjs);
//*****显示登录div end*****
WebElement element =dr.findElement(By.id("j_username"));
element.sendKeys("");
WebElement elementPWD = dr.findElement(By.id("j_password"));
elementPWD.sendKeys("");
element.submit();
String newproc = "document.getElementsByClassName('averatec')[0].click();";
js.executeScript(newproc);
String[] windowHandles = dr.getWindowHandles().toArray(new String[0]);
dr.switchTo().window(windowHandles[1]);
dr.findElement(By.id("productName")).sendKeys("今天天气真好啊!");
Selenium
最新推荐文章于 2023-10-17 10:34:40 发布