https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver网站
•在Windows Vista或Windows 7上的IE 7或更高版本上,必须将每个区域的“保护模式”设置设置为相同的值。该值可以打开或关闭,只要每个区域的值相同即可。要设置保护模式设置,请从“工具”菜单中选择“Internet选项…”,然后单击“安全”选项卡。对于每个区域,标签为“启用保护模式”的选项卡底部都会有一个复选框。
-----------------------------已编辑---------------------------------------
我看到了实际的问题,你基本上有两个不同的网络驱动程序。1在主测试上,另1在Login类上。我建议您将Web驱动程序从main传递到Login类
公共类登录{WebDriver驱动程序;公共登录(String用户名、String BrandName、WebDriver驱动程序){driver=驾驶员;//将main中的驱动程序分配给该Login类driver.findElement(By.xpath(“//input[@name='UserNameInputText']”).sendKeys(Us-erName);driver.findElement(By.xpath(“//input[@name='Brand']”).sendKeys(BrandName);driver.findElement(By.xpath(“//input[@name='CmdLogin']”).click();字符串标题=driver.getTitle();//等等。。。}}
然后在你的主机上
@测试public void LogintoSystem(){driver.manage().window().maximize();司机。get(“http://segotn11540.rds.volvo.com/vss_connect_testr1/Login/Login.aspx");登录名=新登录名(“TYP40FI”,“沃尔沃”,驾驶员);//超过驾驶员}
因此,您具有相同会话的相同驱动程序。
-----------编辑2---------------------
删除Login类中的WebDriver并使用driver参数来完成此工作。
公共类登录{公共登录(String用户名、String BrandName、WebDriver驱动程序){Driver.findElement(By.xpath(“//input[@name='UserNameInputText']”).sendKeys(Us-erName);Driver.findElement(By.xpath(“//input[@name='Brand']”).sendKeys(BrandName);Driver.findElement(By.xpath(“//input[@name='CmdLogin']”).click();字符串标题=Driver.getTitle();//等等。。。}}
主管道保持不变。