我在Webdriver中运行以下脚本时收到错误。 错误消息:此页面行27上的脚本中发生错误
package Example;
import java.util.Iterator;
import java.util.Set;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
//import org.openqa.selenium.WebElement;
public class Script {
public static void main(String args[])throws Exception
{
WebDriver driver = new InternetExplorerDriver();
driver.get("https://www.700creditsolution.com");
driver.manage().window().maximize();
Set<String> windowids = driver.getWindowHandles();
Iterator<String> iter= windowids.iterator();
while(iter.hasNext())
{
System.out.println("Main Window ID :"+iter.next());
}
driver.findElement(By.id("lgnLogin_UserName")).clear();
driver.findElement(By.id("lgnLogin_UserName")).sendKeys("skumara4");
driver.findElement(By.id("lgnLogin_Password")).clear();
driver.findElement(By.id("lgnLogin_Password")).sendKeys("Test1234");
driver.findElement(By.id("lgnLogin_LoginButton")).click();
Thread.sleep(5000L);
windowids = driver.getWindowHandles();
iter= windowids.iterator();
String main_windowID=iter.next();
String tabbed_windowID=iter.next();
System.out.println("Popup Window ID :"+main_windowID);
//switch over to pop-up window
driver.switchTo().window(tabbed_windowID);
System.out.println("Pop-up window Title : "+driver.getTitle());
driver.findElement(By.xpath("//*[@id='BtnClose']")).click();
Thread.sleep(1000);
driver.switchTo().window(main_windowID);
String msg= driver.findElement(By.xpath("//table[@id='lgnLogin']/tbody/tr/td/table/tbody/tr[4]/td")).getText();
System.out.println(msg);
Thread.sleep(1000);
driver.quit();
}
}
打印弹出窗口标题后出现错误。
答案 0 :(得分:0)
基于复制粘贴代码,我的第27行是
Thread.sleep(5000L);
显示错误的原因是因为还有一个“L
”
你可能想要的是
Thread.sleep(5000); # A 5 second wait