How to hide FirefoxDriver (using Selenium) without findElement function error in PhantomDriver(headless browser)?

前端 未结 3 704
Happy的楠姐
Happy的楠姐 2021-01-16 11:09

I try to make hidden FirefoxDriver. According to my research I must use PhantomJSDriver but when I use PhantomJSDriver driver.FindElement statement no longer does not work.<

3条回答
  •  礼貌的吻别
    2021-01-16 11:29

    Since version 55+ for Linux and 56+ for Windows & OSX, Firefox supports the -headless command line option. It shall be used like this:

    o = selenium.webdriver.FirefoxOptions()
    o.set_headless()
    driver=selenium.webdriver.Firefox(options=o)
    

    The corresponding code in C# would be:

    var o = new FirefoxOptions()
    o.AddArgument('-headless')
    var driver = new FirefoxDriver(o)
    

    Because the .NET wrapper doesn't support the .headless property.

提交回复
热议问题