2017-10-11 134 views
1

其實我已經安裝了所有最新版本。我的Firefox瀏覽器啓動。但URL不被調用。Webdriver:啓動瀏覽器。但使用GeckoDriver時不會調用URL

以下是我的系統詳細信息。 操作系統:Ubuntu的14.04 的Firefox版本:56.0 Selenium服務器:硒服務器獨立-3.6.0 GeckoDriver:geckodriver-v0.19.0-LINUX64

瀏覽器啓動代碼

if(BrowserCode.equalsIgnoreCase("FF")) 
      { 
       System.setProperty("webdriver.gecko.driver",System.getProperty("user.dir")+"/AllDrivers/geckodriver"); 
DesiredCapabilities capabilities = DesiredCapabilities.firefox(); 
capabilities.setCapability("marionette", true); 
WebDriver driver = new FirefoxDriver(capabilities); 

} 

我得到隨之而來。任何人都可以在這裏幫助我。

[TestNG] Running: 
    /home/vishalpachpute/workspace/ER_CustomerCare/ERCC_Login.xml 

/home/vishalpachpute/workspace/ER_CustomerCare 
1507724942300 geckodriver INFO geckodriver 0.19.0 
1507724942306 geckodriver INFO Listening on 127.0.0.1:3966 
1507724942723 mozrunner::runner INFO Running command: "/usr/lib/firefox/firefox" "-marionette" "-profile" "/tmp/rust_mozprofile.qsoDFMATTikn" 
1507724942948 addons.xpi WARN Error parsing extensions state: [Exception... "Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [amIAddonManagerStartup.readStartupData]" nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)" location: "JS frame :: resource://gre/modules/addons/XPIProvider.jsm :: loadExtensionState :: line 1554" data: no] Stack trace: loadExtensionState()@resource://gre/modules/addons/XPIProvider.jsm:1554 < getInstallState()@resource://gre/modules/addons/XPIProvider.jsm:1589 < checkForChanges()@resource://gre/modules/addons/XPIProvider.jsm:3109 < startup()@resource://gre/modules/addons/XPIProvider.jsm:2188 < callProvider()@resource://gre/modules/AddonManager.jsm:269 < _startProvider()@resource://gre/modules/AddonManager.jsm:739 < startup()@resource://gre/modules/AddonManager.jsm:906 < startup()@resource://gre/modules/AddonManager.jsm:3090 < observe()@jar:file:///usr/lib/firefox/omni.ja!/components/addonManager.js:65 
1507724943785 Marionette INFO Enabled via --marionette 

(firefox:22169): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed 

(firefox:22169): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed 

(firefox:22169): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed 

(firefox:22169): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed 

(/usr/lib/firefox/firefox:22219): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed 

(/usr/lib/firefox/firefox:22219): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed 

(/usr/lib/firefox/firefox:22219): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed 

(/usr/lib/firefox/firefox:22219): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed 
1507724946494 Marionette INFO Listening on port 38903 
1507725070118 Marionette WARN TLS certificate errors will be ignored for this session 
1507725070153 Marionette DEBUG Register listener.js for window 2147483649 
Oct 11, 2017 6:01:10 PM org.openqa.selenium.remote.ProtocolHandshake createSession 
INFO: Detected dialect: W3C 
1507725070269 Marionette DEBUG Received DOM event "beforeunload" for "about:blank" 
1507725160564 Marionette DEBUG Received DOM event "beforeunload" for "about:blank" 
1507725160566 Marionette DEBUG Received DOM event "pagehide" for "about:blank" 
1507725160567 Marionette DEBUG Received DOM event "unload" for "about:blank" 
1507725160612 Marionette DEBUG Received DOM event "DOMContentLoaded" for "about:neterror?e=netTimeout&u=http%3A//localhost%3A8888/ercc/&c=UTF-8&f=regular&d=The%20server%20at%20localhost%20is%20taking%20too%20long%20to%20respond." 
org.openqa.selenium.WebDriverException: Reached error page: about:neterror?e=netTimeout&u=http%3A//localhost%3A8888/ercc/&c=UTF-8&f=regular&d=The%20server%20at%20localhost%20is%20taking%20too%20long%20to%20respond. 
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:26.402Z' 
System info: host: 'vfrootThinkPadT450', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-30-generic', java.version: '1.8.0_111' 
Driver info: org.openqa.selenium.firefox.FirefoxDriver 
Capabilities [{moz:profile=/tmp/rust_mozprofile.qsoDFMATTikn, rotatable=false, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, moz:headless=false, platform=LINUX, specificationLevel=0, moz:accessibilityChecks=false, acceptInsecureCerts=true, browserVersion=56.0, platformVersion=3.16.0-30-generic, moz:processID=22169, browserName=firefox, javascriptEnabled=true, platformName=LINUX}] 
Session ID: 12542456-e71a-40f4-944d-c476840f3c99 
    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:83) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586) 
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:310) 
    at com.vodafone.er.cc.test.integration.PlatformLayer.LaunchApplication.Execute(LaunchApplication.java:173) 
    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.invokeConfigurationMethod(Invoker.java:510) 
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211) 
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138) 
    at org.testng.TestRunner.beforeRun(TestRunner.java:648) 
    at org.testng.TestRunner.run(TestRunner.java:616) 
    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.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132) 
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236) 
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81) 

=============================================== 
ER 
Total tests run: 1, Failures: 0, Skips: 1 
Configuration Failures: 1, Skips: 1 
=============================================== 

附上了我的全LaunchApplication.java文件以獲取更多詳細信息

package com.vodafone.er.cc.test.integration.PlatformLayer; 

import java.io.File; 
import java.io.IOException; 
import java.net.MalformedURLException; 
import java.net.URL; 
//import java.sql.Date; 
import java.util.Date; 
import java.text.DateFormat; 
import java.text.SimpleDateFormat; 
import java.util.concurrent.TimeUnit; 

import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.chrome.*; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.firefox.FirefoxOptions; 
import org.openqa.selenium.firefox.FirefoxProfile; 
import org.openqa.selenium.ie.InternetExplorerDriver; 
import org.openqa.selenium.remote.DesiredCapabilities; 
import org.openqa.selenium.remote.RemoteWebDriver; 
import org.testng.Assert; 
import org.testng.Reporter; 
import org.testng.annotations.AfterTest; 
import org.testng.annotations.BeforeTest; 
import org.testng.annotations.Parameters; 

import atu.testng.reports.ATUReports; 
import atu.testrecorder.ATUTestRecorder; 
import atu.testrecorder.exceptions.ATUTestRecorderException; 

import org.openqa.selenium.phantomjs.PhantomJSDriver; 
import org.openqa.selenium.phantomjs.PhantomJSDriverService; 
import org.openqa.selenium.remote.DesiredCapabilities; 



/*@Listeners({ ATUReportsListener.class, ConfigurationListener.class, 
    MethodListener.class })*/ 

public class LaunchApplication { 

    { 
     System.setProperty("atu.reporter.config", "./atu.properties"); 

    } 


    public static WebDriver driver=null; 
    ATUTestRecorder recorder; 
    Date date; 

    @BeforeTest (alwaysRun = true) 
    @Parameters({"RunUsingSG","BrowserCode","URL","Title","Platform","Version"}) 
    public void Execute(String RunUsingSG,String BrowserCode,String URL,String Title,String Platform,String Version) throws IOException, InterruptedException, ATUTestRecorderException 
    { 

     System.out.println(System.getProperty("user.dir")); 
      DesiredCapabilities dc=new DesiredCapabilities(); 

      //This code is for recording. if you want to do recording, just uncomment the following code. 
      /*DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH-mm-ss"); 
      Date date = new Date(); 
      // For Recording the Execution using ATU Reporter. 
      recorder = new ATUTestRecorder("./ScriptVideos","TestVideo-" +dateFormat.format(date),false); 
      recorder.start();*/ 

      // For IE 32 Bits 
      if(BrowserCode.equalsIgnoreCase("IE32")) 
      { 
       dc.setBrowserName("internet explorer"); 
       dc.setVersion(Version); 
       if(RunUsingSG.equalsIgnoreCase("Y")) 
       {driver=new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),dc);} 
       else 
       { 
        System.setProperty("webdriver.ie.driver",System.getProperty("user.dir")+"/AllDrivers/IEDriverServer_32bit_OS.exe"); 
        driver = new InternetExplorerDriver(); 
       } 
      } 

      // For PhantomJS 
      if(BrowserCode.equalsIgnoreCase("PJS")) 
      { 

       dc.setJavascriptEnabled(true); 
       dc.setVersion(Version); 
       dc.setBrowserName("Phantom JS"); 
       dc.setCapability("phantomjs.binary", "/AllDrivers/phantomjs"); 

       driver = new PhantomJSDriver(dc); 

      } 

      //For IE 64 Bits 
      if(BrowserCode.equalsIgnoreCase("IE64")) 
      { 
       //System.setProperty("webdriver.ie.driver",System.getProperty("user.dir")+"/AllDrivers/IEDriverServer_64bit_OS.exe"); 
       System.setProperty("webdriver.ie.driver",System.getProperty("user.dir")+"/AllDrivers/IEDriverServer_x64_2.41.0/IEDriverServer_V2.41_64bit.exe"); 
       dc.setBrowserName("internet explorer"); 
       dc.setVersion(Version); 
       if(RunUsingSG.equalsIgnoreCase("Y")) 
       { 
        driver=new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),dc); 
       } 
       else 
       { 
        //System.setProperty("webdriver.ie.driver",System.getProperty("user.dir")+"/AllDrivers/IEDriverServer_64bit_OS.exe"); 
        System.setProperty("webdriver.ie.driver",System.getProperty("user.dir")+"/AllDrivers/IEDriverServer_x64_2.41.0/IEDriverServer_V2.41_64bit.exe"); 

        driver = new InternetExplorerDriver();} 
      } 


      /*//For Firefox 
      if(BrowserCode.equalsIgnoreCase("FF")) 
      { 

       FirefoxProfile firefoxProfile = new FirefoxProfile(); 
       dc.setBrowserName("firefox"); 
       //dc.setVersion(Version); 
       if(RunUsingSG.equalsIgnoreCase("Y")) 
       { 
        driver=new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),dc); 
       } 
       else 
       { 
        driver=new FirefoxDriver(); 

       } 
      }*/ 

      //For Firefox GeckoDriver 
      if(BrowserCode.equalsIgnoreCase("FF")) 
      { 
       System.setProperty("webdriver.gecko.driver",System.getProperty("user.dir")+"/AllDrivers/geckodriver"); 
       DesiredCapabilities capabilities = DesiredCapabilities.firefox(); 
       capabilities.setCapability("marionette", true); 
       driver = new FirefoxDriver(capabilities); 

       driver.get("URL"); 

      } 



      // For Chrome 
      if(BrowserCode.equalsIgnoreCase("CH")) 
      { 

       ChromeOptions options = new ChromeOptions(); 
       options.addArguments("test-type"); 
       dc.setCapability("chrome.binary","./AllDrivers/chromedriver/"); 
       dc.setCapability(ChromeOptions.CAPABILITY, options); 

       dc.setBrowserName("Google Chrome"); 
       dc.setVersion(Version); 
       if(RunUsingSG.equalsIgnoreCase("Y")) 
       { 
        driver=new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),dc); 
       } 
       else 
       { 
        System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+"/AllDrivers/chromedriver"); 
        driver = new ChromeDriver(dc); 
       } 
      } 





      if(Platform.equalsIgnoreCase("WINDOWS")) 
      try 
      { 
      {dc.setPlatform(org.openqa.selenium.Platform.WINDOWS);} 
      driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS); 
      driver.get(URL); 
      Thread.sleep(3000); 
      Assert.assertEquals(driver.getTitle(), Title); 
      driver.manage().window().maximize(); 
      Thread.sleep(2000); 

      // ATU Reports 
      ATUReports.setWebDriver(LaunchApplication.driver); 
      ATUReports.indexPageDescription = "ER-CC Automation Scripts Results."; 


      } 
      catch (Exception e) 
      { 
       Reporter.log("Exception occured " +e.getMessage()); 
       e.printStackTrace(); 
       Assert.fail(); 
       driver.quit(); 
      } 

    } 



    @AfterTest 
    //@Parameters({"RunUsingSG","BrowserCode","URL","Title","Platform","Version"}) 
    public void TearDown() throws MalformedURLException, ATUTestRecorderException 
    { 
     driver.close(); 
     //driver.quit(); 
     //recorder.stop(); 

    } 
} 
+0

他的代碼,不要有任何URL – iamsankalp89

回答

0

這個代碼不具有任何URL

if(BrowserCode.equalsIgnoreCase("FF")) 
{ 
System.setProperty("webdriver.gecko.driver",System.getProperty("user.dir")+"/AllDrivers/geckodriver"); 
DesiredCapabilities capabilities = DesiredCapabilities.firefox(); 
capabilities.setCapability("marionette", true); 
WebDriver driver = new FirefoxDriver(capabilities); 
driver.get("URL"); //add it 
} 
+0

嗨..其實我添加的驅動程序。按您的建議在代碼中設置(「URL」)。但面臨同樣的問題。你能幫我解決這個問題嗎?提前致謝。此外,它在那裏已經在我的其他塊如果。 –

+0

此外,我添加了我的LaunchApplication.java文件以獲取更多詳細信息。請檢查原始帖子。 –

+0

好的共享我的代碼 – iamsankalp89

相關問題