无法通过Jenkins使用IE浏览器运行selenium

时间:2017-09-06 18:25:55

标签: selenium jenkins

Selenium version 3.5
IEDriverserver - 3.5.0
IE version - 11
Jenkins version 2.75

    private static final WebDriver WebDriverRefrence = null;{
        }
        public WebDriver driver ; 

         @BeforeTest
          public  void launchBrowser() {
            Logger.getRootLogger().setLevel(Level.OFF);
            System.setProperty("webdriver.ie.driver","C:\\AUTOMATION\\IEDriverServer.exe");

                //Turn ON Protected Mode for the IE Browser
                DesiredCapabilities aots = DesiredCapabilities.internetExplorer();
                aots.setCapability("nativeEvents",false);
                aots.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);       
            driver = new InternetExplorerDriver(aots)           
            driver.get("https://www.gmail.com");

         }   
         @Test
         public void Test_case_001() throws  InterruptedException {

        driver.findElement(By.id("identifierId")).sendKeys("abc");
        Thread.sleep(1000);
        driver.findElement(By.xpath(".//*[@id='identifierNext']/div[2]")).click();
        Thread.sleep(3000);
        driver.findElement(By.xpath(".//*[@id='password']/div[1]/div/div[1]/input")).sendKeys("XXXXXX");
        Thread.sleep(2000);
        driver.findElement(By.xpath(".//*[@id='passwordNext']/div[2]")).click();
}
}

我有一个简单的Selenium代码来登录Gmail。 我能够从eclipse(IE浏览器)成功运行 我能够从eclipse(FF浏览器)成功运行 我能通过Jenkins(FF浏览器)成功运行 但是当我使用IE浏览器并通过Jenkins运行时,它会失败。 代码和错误如下。不知道为什么在通过Jenkins运行时找不到元素。

以下是测试输出文件的错误:

-<test-method finished-at="2017-09-06T13:47:33Z" started-at="2017-09-06T13:47:26Z" duration-ms="6405" name="Test_case_001" signature="Test_case_001()[pri:0, instance:test2.practice@4c75cab9]" status="FAIL">


-<exception class="org.openqa.selenium.NoSuchElementException">


-<message>

-<![CDATA[Unable to find element with xpath == .//*[@id='password']/div[1]/div/div[1]/input
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'DESKTOP-E0D9KLG', ip: '135.70.196.248', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_92'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{acceptInsecureCerts=false, browserVersion=11, se:ieOptions={nativeEvents=true, browserAttachTimeout=0.0, ie.ensureCleanSession=false, elementScrollBehavior=0.0, enablePersistentHover=true, ie.browserCommandLineSwitches=, ie.forceCreateProcessApi=false, requireWindowFocus=false, initialBrowserUrl=http://localhost:43511/, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000.0, ignoreProtectedModeSettings=true}, browserName=internet explorer, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss, javascriptEnabled=true, platformName=windows, setWindowRect=true, platform=ANY}]
Session ID: 1baa5458-8f37-4e13-9119-08b88aba17f0
*** Element info: {Using=xpath, value=.//*[@id='password']/div[1]/div/div[1]/input}]]>
</message>


-<full-stacktrace>

-<![CDATA[org.openqa.selenium.NoSuchElementException: Unable to find element with xpath == .//*[@id='password']/div[1]/div/div[1]/input
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'DESKTOP-E0D9KLG', ip: '135.70.196.248', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_92'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{acceptInsecureCerts=false, browserVersion=11, se:ieOptions={nativeEvents=true, browserAttachTimeout=0.0, ie.ensureCleanSession=false, elementScrollBehavior=0.0, enablePersistentHover=true, ie.browserCommandLineSwitches=, ie.forceCreateProcessApi=false, requireWindowFocus=false, initialBrowserUrl=http://localhost:43511/, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000.0, ignoreProtectedModeSettings=true}, browserName=internet explorer, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss, javascriptEnabled=true, platformName=windows, setWindowRect=true, platform=ANY}]
Session ID: 1baa5458-8f37-4e13-9119-08b88aba17f0
*** Element info: {Using=xpath, value=.//*[@id='password']/div[1]/div/div[1]/input}
    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.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:641)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:414)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:513)
    at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:406)
    at test2.practice.Test_case_001(practice.java:79)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
    at org.testng.TestRunner.privateRun(TestRunner.java:774)
    at org.testng.TestRunner.run(TestRunner.java:624)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
    at org.testng.SuiteRunner.run(SuiteRunner.java:261)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
    at org.testng.TestNG.run(TestNG.java:1048)
    at org.testng.TestNG.privateMain(TestNG.java:1355)
    at org.testng.TestNG.main(TestNG.java:1324)

0 个答案:

没有答案