Selenium 脚本未在 IE11 中打开 URL
Selenium script is not opening URL in IE11
我有下面的 selenium 脚本来启动 URL,但是当我 运行 时总是出错。我搜索了堆栈溢出和其他网站,但 none 的解决方案对我有用。
尝试过的解决方案:
1.将所有安全值设置为同一级别(高)
2. 启用或禁用所有安全设置。
代码:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class Automation{
static String driverPath = "IE driver path";
public WebDriver driver;
@BeforeClass
public void setUp() {
System.out.println("*******************");
System.out.println("launching IE browser");
System.setProperty("webdriver.ie.driver", ".\ieDriver\IEDriverServer.exe");
driver = new InternetExplorerDriver();
driver.manage().window().maximize();
}
@Test
public void testGooglePageTitleInIEBrowser() {
driver.navigate().to("http://www.google.com");
String strPageTitle = driver.getTitle();
System.out.println("Page title: - "+strPageTitle);
Assert.assertTrue(strPageTitle.equalsIgnoreCase("Google"), "Page title doesn't match");
}
@AfterClass
public void tearDown() {
if(driver!=null) {
System.out.println("Closing IE browser");
driver.quit();
}
}
}
抛出错误:
"C:\Program Files (x86)\Java\jdk1.8.0_121\bin\java" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4\lib\idea_rt.jar=52446:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4\plugins\testng\lib\testng-plugin.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\charsets.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\deploy.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\access-bridge-32.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\cldrdata.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\dnsns.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\jaccess.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\jfxrt.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\localedata.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\nashorn.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\sunec.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\sunjce_provider.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\sunmscapi.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\sunpkcs11.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\zipfs.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\javaws.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\jce.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\jfr.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\jfxswt.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\jsse.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\management-agent.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\plugin.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\resources.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\rt.jar;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\out\test\classes;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\out\test\resources;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\out\production\resources;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-java.53.05a24b52c9e5704e900ac755b5800352e981af7\selenium-java-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.testng\testng.9.9bf509349476d6a48978cc2b04af9caa907781ab\testng-6.9.9.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\com.relevantcodes\extentreports.40.24ab4559804e499184e546754116e4b3d53e106\extentreports-2.40.2.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.pdfbox\pdfbox.0.7\b1beed06441f7404a7702a069823ab56782aee2e\pdfbox-2.0.7.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-lang3.15075e6c80f206bbe6cf1e809d2caa69f420c76\commons-lang3-3.1.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\com.itextpdf\itextpdf.4.03f5da44e7072abd385ecee05279353d79bea47\itextpdf-5.4.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\dom4j\dom4j.6.1d3ccc056b6f056dbf0dddfdf43894b9065a8f94\dom4j-1.6.1.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.poi\poi.13\f59f504ba8c521e61e25f417ec652fd485010f3\poi-3.13.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.poi\poi-scratchpad.13d763275e6c7fa05d47e2581606748669e88c55\poi-scratchpad-3.13.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.poi\poi-ooxml.13\c364a8f5422d613e3a56db3b4b889f2989d7ee73\poi-ooxml-3.13.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.json\json090211\c183aa3a2a6250293808bba12262c8920ce5a51c\json-20090211.jar;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\src\lib\ojdbc14.jar;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\src\lib\itextpdf-5.4.0.jar;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\src\lib\sikuli-script.jar;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\src\lib\xmlbeans-2.6.0.jar;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\src\lib\log4j-1.2.17.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\junit\junit.1273d150c0dc1fefe998f834810d68f278ea58ec\junit-4.12.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-chrome-driver.53.041a3948c3fb31122ee9633731e8103f3292b0a\selenium-chrome-driver-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-edge-driver.53.0f3da0dfa620ae8cd71afacfdd6ddae5028ce1ea\selenium-edge-driver-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-firefox-driver.53.0dc655b1999898d2fc3791c649b7355d98629a69\selenium-firefox-driver-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-ie-driver.53.0b703e9fba9c0f636109cf4bd697c1f208ac825\selenium-ie-driver-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-safari-driver.53.0\c80224258a8b702c99f2d7b3847ce89dc1bcd2bd\selenium-safari-driver-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-support.53.006aa8a696d1b7938365a41ee7ca46309a0b2d\selenium-support-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-leg-rc.53.0\bdabcf672449c588913ae32973dd8f7d54f510de\selenium-leg-rc-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\com.beust\jcommander.48\bfcb96281ea3b59d626704f74bc6d625ff51cbce\jcommander-1.48.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.ant\ant.7.046af1a485e50cf18dcb232489032a847067066\ant-1.7.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml.15b132bea69e8ee099f416044970997bde80f4ea6\snakeyaml-1.15.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.beanshell\bsh.0b4\a05f0a0feefa8d8467ac80e16e7de071489f0d9c\bsh-2.0b4.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.jsoup\jsoup.8.3fd012581ded67bc20945d85c32b4598c3a9cf1\jsoup-1.8.3.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.xerial\sqlite-jdbc.8.11.1\b33358a3e242b21f2fe518dc1471fab0a49a04a\sqlite-jdbc-3.8.11.1.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.freemarker\freemarker.3.23\cd143cd8c02a9f838e3cb75a6dfe133750437f6d\freemarker-2.3.23.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.pdfbox\fontbox.0.7321d36cfbd7f2c15f24b67fdcc88c66b453379\fontbox-2.0.7.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\commons-logging\commons-logging.2bfc12adfe4842bf07b657f0369c4cb522955686\commons-logging-1.2.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\xml-apis\xml-apis.0.b236ca936f64c9d68529f048c2618bd356bf85c9\xml-apis-1.0.b2.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\commons-codec\commons-codec.9ce04e34240f674bc72680f8b843b1457383161a\commons-codec-1.9.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.poi\poi-ooxml-schemas.13fb0b9f3ffc3d7f7fc9b59e17b5fa2c3ab921e7\poi-ooxml-schemas-3.13.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-remote-driver.53.0\eb76ed037ba5a7c11cce11effd0e2175056905ac\selenium-remote-driver-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\commons-io\commons-io.4\b1b6ea3b7e4aa4f492509a4952029cd8e48019ad\commons-io-2.4.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-exec.3dfb9facd0830a27b1b5f29f84593f0aeee7773b\commons-exec-1.3.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\net.java.dev.jna\jna.1.0c12d070e602efd8021891cdd7fd18bc129372d4\jna-4.1.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\net.java.dev.jna\jna-platform.1.0457ad1cf75c2c16763330de5565a0e67b4bc0a\jna-platform-4.1.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\io.netty\netty.5.7.Final1465e6dfc89d7c78d21de6a9747b6046cb5403\netty-3.5.7.Final.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.ant\ant-launcher.7.0\e7e30789211e074aa70ef3eaea59bd5b22a7fa7a\ant-launcher-1.7.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.xmlbeans\xmlbeans.6.0e80d2dd51f9dcdef8f9ffaee0d4dc1c9bbfc87\xmlbeans-2.6.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\cglib\cglib-nodep.1_3d3be5953547c0019e5704`enter code here`d6ed4ffda3b0c7c66\cglib-nodep-2.1_3.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\com.google.code.gson\gson.3.1\ecb6e1f8e4b0e84c4b886c2f14a1500caf309757\gson-2.3.1.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-api.53.0\a6105ad5c43dcc02c1cf87250111b0a7f1a7c2e6\selenium-api-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpclient.5.1e3cecc566df91338c6c67883b89ddd05a17db43\httpclient-4.5.1.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\com.google.guava\guava.0ce200f6b23222af3d8abb6b6459e6c44f4bb0e9\guava-19.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\stax\stax-api.0.1c100caf72d658aca8e58bd74a4ba90fa2b0d70\stax-api-1.0.1.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpcore.4.3\e876a79d561e5c6207b78d347e198c8c4531a5e5\httpcore-4.4.3.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.hamcrest\hamcrest-core.3a25dc3219429f0e5d060061f71acb49bf010a0\hamcrest-core-1.3.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4\plugins\testng\lib\jcommander.jar" org.testng.RemoteTestNGStarter -usedefaultlisteners false -socket52445 @w@C:\Users\kiran.venkatesan\AppData\Local\Temp\idea_working_dirs_testng.tmp -temp C:\Users\kiran.venkatesan\AppData\Local\Temp\idea_testng.tmp
[TestNG] Running:
C:\Users\kiran.venkatesan\.IdeaIC2017.3\system\temp-testng-customsuite.xml
*******************
launching IE browser
Started InternetExplorerDriver server (32-bit)
3.9.0.0
Listening on port 48142
Only local connections are allowed
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
org.openqa.selenium.remote.SessionNotFoundException: session null does not exist (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 23 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'BDC4-L-9XMLTF2', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{capabilities={proxy={}, acceptInsecureCerts=false, browserVersion=11, se:ieOptions={nativeEvents=true, browserAttachTimeout=0, ie.ensureCleanSession=false, elementScrollBehavior=0, enablePersistentHover=true, ie.browserCommandLineSwitches=, ie.forceCreateProcessApi=false, requireWindowFocus=false, initialBrowserUrl=http://localhost:48142/, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, ignoreProtectedModeSettings=false}, timeouts={implicit=0, pageLoad=300000, script=30000}, browserName=internet explorer, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss, platformName=windows, setWindowRect=true}, sessionId=c1b66a88-1f49-4f1a-9348-23500ef57966, platform=ANY}]
Session ID: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:701)
错误说明了一切:
Started InternetExplorerDriver server (32-bit)
3.9.0.0
org.openqa.selenium.remote.SessionNotFoundException: session null does not exist (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 23 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'BDC4-L-9XMLTF2', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
从你的错误堆栈跟踪中可以清楚地看出,新的 session 没有被启动并且 Driver info 也没有被识别.
您的主要问题是您使用的二进制文件之间的版本兼容性,如下所示:
- 您正在使用 IEDriverServer v3.9.0.0
- 您正在使用 InternetExplorer v11.0(根据您的问题)
- 您正在使用 Selenium 客户端 v2.53.0 2016-03-15 10:43:46 差不多 2 岁了。
- 你的 JDK 版本 是 1.8.0_121 这是相当古老的。
因此 JDK v8u121、Selenium Client v2.53.0、[=27= 之间存在明显的不匹配]Chrome驱动程序版本(v2.36)和Chrome浏览器版本(v65.0)
解决方案
- 将 JDK 升级到最近的水平 JDK 8u162。
- 将 Selenium 客户端 升级到 v3.11.0。
- 将 IEDriverServer 升级到 v3.11.1。
- 清理您的项目工作区通过您的IDE和重建你的项目只需要依赖。
- 使用 CCleaner 工具清除执行 测试套件 .
前后的所有 OS 琐事
- 如果您的基本 Web 浏览器 基本版本太旧,则通过 Revo Uninstaller 卸载它并安装最新的 GA 和发布版本的 Web浏览器.
- 执行你的
@Test
.
我有下面的 selenium 脚本来启动 URL,但是当我 运行 时总是出错。我搜索了堆栈溢出和其他网站,但 none 的解决方案对我有用。
尝试过的解决方案: 1.将所有安全值设置为同一级别(高) 2. 启用或禁用所有安全设置。
代码:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class Automation{
static String driverPath = "IE driver path";
public WebDriver driver;
@BeforeClass
public void setUp() {
System.out.println("*******************");
System.out.println("launching IE browser");
System.setProperty("webdriver.ie.driver", ".\ieDriver\IEDriverServer.exe");
driver = new InternetExplorerDriver();
driver.manage().window().maximize();
}
@Test
public void testGooglePageTitleInIEBrowser() {
driver.navigate().to("http://www.google.com");
String strPageTitle = driver.getTitle();
System.out.println("Page title: - "+strPageTitle);
Assert.assertTrue(strPageTitle.equalsIgnoreCase("Google"), "Page title doesn't match");
}
@AfterClass
public void tearDown() {
if(driver!=null) {
System.out.println("Closing IE browser");
driver.quit();
}
}
}
抛出错误:
"C:\Program Files (x86)\Java\jdk1.8.0_121\bin\java" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4\lib\idea_rt.jar=52446:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4\plugins\testng\lib\testng-plugin.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\charsets.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\deploy.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\access-bridge-32.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\cldrdata.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\dnsns.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\jaccess.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\jfxrt.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\localedata.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\nashorn.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\sunec.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\sunjce_provider.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\sunmscapi.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\sunpkcs11.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\ext\zipfs.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\javaws.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\jce.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\jfr.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\jfxswt.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\jsse.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\management-agent.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\plugin.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\resources.jar;C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\rt.jar;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\out\test\classes;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\out\test\resources;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\out\production\resources;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-java.53.05a24b52c9e5704e900ac755b5800352e981af7\selenium-java-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.testng\testng.9.9bf509349476d6a48978cc2b04af9caa907781ab\testng-6.9.9.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\com.relevantcodes\extentreports.40.24ab4559804e499184e546754116e4b3d53e106\extentreports-2.40.2.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.pdfbox\pdfbox.0.7\b1beed06441f7404a7702a069823ab56782aee2e\pdfbox-2.0.7.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-lang3.15075e6c80f206bbe6cf1e809d2caa69f420c76\commons-lang3-3.1.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\com.itextpdf\itextpdf.4.03f5da44e7072abd385ecee05279353d79bea47\itextpdf-5.4.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\dom4j\dom4j.6.1d3ccc056b6f056dbf0dddfdf43894b9065a8f94\dom4j-1.6.1.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.poi\poi.13\f59f504ba8c521e61e25f417ec652fd485010f3\poi-3.13.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.poi\poi-scratchpad.13d763275e6c7fa05d47e2581606748669e88c55\poi-scratchpad-3.13.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.poi\poi-ooxml.13\c364a8f5422d613e3a56db3b4b889f2989d7ee73\poi-ooxml-3.13.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.json\json090211\c183aa3a2a6250293808bba12262c8920ce5a51c\json-20090211.jar;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\src\lib\ojdbc14.jar;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\src\lib\itextpdf-5.4.0.jar;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\src\lib\sikuli-script.jar;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\src\lib\xmlbeans-2.6.0.jar;C:\Users\kiran.venkatesan\Desktop\Code Base\New Order Create - Automation\NOC Automation - gradle project\src\lib\log4j-1.2.17.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\junit\junit.1273d150c0dc1fefe998f834810d68f278ea58ec\junit-4.12.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-chrome-driver.53.041a3948c3fb31122ee9633731e8103f3292b0a\selenium-chrome-driver-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-edge-driver.53.0f3da0dfa620ae8cd71afacfdd6ddae5028ce1ea\selenium-edge-driver-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-firefox-driver.53.0dc655b1999898d2fc3791c649b7355d98629a69\selenium-firefox-driver-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-ie-driver.53.0b703e9fba9c0f636109cf4bd697c1f208ac825\selenium-ie-driver-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-safari-driver.53.0\c80224258a8b702c99f2d7b3847ce89dc1bcd2bd\selenium-safari-driver-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-support.53.006aa8a696d1b7938365a41ee7ca46309a0b2d\selenium-support-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-leg-rc.53.0\bdabcf672449c588913ae32973dd8f7d54f510de\selenium-leg-rc-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\com.beust\jcommander.48\bfcb96281ea3b59d626704f74bc6d625ff51cbce\jcommander-1.48.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.ant\ant.7.046af1a485e50cf18dcb232489032a847067066\ant-1.7.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml.15b132bea69e8ee099f416044970997bde80f4ea6\snakeyaml-1.15.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.beanshell\bsh.0b4\a05f0a0feefa8d8467ac80e16e7de071489f0d9c\bsh-2.0b4.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.jsoup\jsoup.8.3fd012581ded67bc20945d85c32b4598c3a9cf1\jsoup-1.8.3.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.xerial\sqlite-jdbc.8.11.1\b33358a3e242b21f2fe518dc1471fab0a49a04a\sqlite-jdbc-3.8.11.1.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.freemarker\freemarker.3.23\cd143cd8c02a9f838e3cb75a6dfe133750437f6d\freemarker-2.3.23.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.pdfbox\fontbox.0.7321d36cfbd7f2c15f24b67fdcc88c66b453379\fontbox-2.0.7.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\commons-logging\commons-logging.2bfc12adfe4842bf07b657f0369c4cb522955686\commons-logging-1.2.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\xml-apis\xml-apis.0.b236ca936f64c9d68529f048c2618bd356bf85c9\xml-apis-1.0.b2.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\commons-codec\commons-codec.9ce04e34240f674bc72680f8b843b1457383161a\commons-codec-1.9.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.poi\poi-ooxml-schemas.13fb0b9f3ffc3d7f7fc9b59e17b5fa2c3ab921e7\poi-ooxml-schemas-3.13.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-remote-driver.53.0\eb76ed037ba5a7c11cce11effd0e2175056905ac\selenium-remote-driver-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\commons-io\commons-io.4\b1b6ea3b7e4aa4f492509a4952029cd8e48019ad\commons-io-2.4.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-exec.3dfb9facd0830a27b1b5f29f84593f0aeee7773b\commons-exec-1.3.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\net.java.dev.jna\jna.1.0c12d070e602efd8021891cdd7fd18bc129372d4\jna-4.1.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\net.java.dev.jna\jna-platform.1.0457ad1cf75c2c16763330de5565a0e67b4bc0a\jna-platform-4.1.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\io.netty\netty.5.7.Final1465e6dfc89d7c78d21de6a9747b6046cb5403\netty-3.5.7.Final.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.ant\ant-launcher.7.0\e7e30789211e074aa70ef3eaea59bd5b22a7fa7a\ant-launcher-1.7.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.xmlbeans\xmlbeans.6.0e80d2dd51f9dcdef8f9ffaee0d4dc1c9bbfc87\xmlbeans-2.6.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\cglib\cglib-nodep.1_3d3be5953547c0019e5704`enter code here`d6ed4ffda3b0c7c66\cglib-nodep-2.1_3.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\com.google.code.gson\gson.3.1\ecb6e1f8e4b0e84c4b886c2f14a1500caf309757\gson-2.3.1.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.seleniumhq.selenium\selenium-api.53.0\a6105ad5c43dcc02c1cf87250111b0a7f1a7c2e6\selenium-api-2.53.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpclient.5.1e3cecc566df91338c6c67883b89ddd05a17db43\httpclient-4.5.1.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\com.google.guava\guava.0ce200f6b23222af3d8abb6b6459e6c44f4bb0e9\guava-19.0.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\stax\stax-api.0.1c100caf72d658aca8e58bd74a4ba90fa2b0d70\stax-api-1.0.1.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpcore.4.3\e876a79d561e5c6207b78d347e198c8c4531a5e5\httpcore-4.4.3.jar;C:\Users\kiran.venkatesan\.gradle\caches\modules-2\files-2.1\org.hamcrest\hamcrest-core.3a25dc3219429f0e5d060061f71acb49bf010a0\hamcrest-core-1.3.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4\plugins\testng\lib\jcommander.jar" org.testng.RemoteTestNGStarter -usedefaultlisteners false -socket52445 @w@C:\Users\kiran.venkatesan\AppData\Local\Temp\idea_working_dirs_testng.tmp -temp C:\Users\kiran.venkatesan\AppData\Local\Temp\idea_testng.tmp
[TestNG] Running:
C:\Users\kiran.venkatesan\.IdeaIC2017.3\system\temp-testng-customsuite.xml
*******************
launching IE browser
Started InternetExplorerDriver server (32-bit)
3.9.0.0
Listening on port 48142
Only local connections are allowed
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
org.openqa.selenium.remote.SessionNotFoundException: session null does not exist (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 23 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'BDC4-L-9XMLTF2', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{capabilities={proxy={}, acceptInsecureCerts=false, browserVersion=11, se:ieOptions={nativeEvents=true, browserAttachTimeout=0, ie.ensureCleanSession=false, elementScrollBehavior=0, enablePersistentHover=true, ie.browserCommandLineSwitches=, ie.forceCreateProcessApi=false, requireWindowFocus=false, initialBrowserUrl=http://localhost:48142/, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, ignoreProtectedModeSettings=false}, timeouts={implicit=0, pageLoad=300000, script=30000}, browserName=internet explorer, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss, platformName=windows, setWindowRect=true}, sessionId=c1b66a88-1f49-4f1a-9348-23500ef57966, platform=ANY}]
Session ID: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:701)
错误说明了一切:
Started InternetExplorerDriver server (32-bit)
3.9.0.0
org.openqa.selenium.remote.SessionNotFoundException: session null does not exist (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 23 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'BDC4-L-9XMLTF2', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
从你的错误堆栈跟踪中可以清楚地看出,新的 session 没有被启动并且 Driver info 也没有被识别.
您的主要问题是您使用的二进制文件之间的版本兼容性,如下所示:
- 您正在使用 IEDriverServer v3.9.0.0
- 您正在使用 InternetExplorer v11.0(根据您的问题)
- 您正在使用 Selenium 客户端 v2.53.0 2016-03-15 10:43:46 差不多 2 岁了。
- 你的 JDK 版本 是 1.8.0_121 这是相当古老的。
因此 JDK v8u121、Selenium Client v2.53.0、[=27= 之间存在明显的不匹配]Chrome驱动程序版本(v2.36)和Chrome浏览器版本(v65.0)
解决方案
- 将 JDK 升级到最近的水平 JDK 8u162。
- 将 Selenium 客户端 升级到 v3.11.0。
- 将 IEDriverServer 升级到 v3.11.1。
- 清理您的项目工作区通过您的IDE和重建你的项目只需要依赖。
- 使用 CCleaner 工具清除执行 测试套件 . 前后的所有 OS 琐事
- 如果您的基本 Web 浏览器 基本版本太旧,则通过 Revo Uninstaller 卸载它并安装最新的 GA 和发布版本的 Web浏览器.
- 执行你的
@Test
.