PhantomJS with Selenium Grid 2 - how to disable phantomjsdriver.log?

Viewed 345

I have been trying to find this somewhere in the documentation, but can't seem to find anything relevant - could anybody share how to disable the logs created by a Selenium Grid node, in the file phantomjsdriver.log, (or if not, only write at a given level, e.g ERROR or WARN)?

I've come across an issue recently where WebDriver will run fine for a while using PhantomJS remotely via Selenium Grid, but after some time there seems to be a bug which causes a StackOverflowException to be thrown when trying to interact with driver instances - which I think I've tracked down to the size of the phantomjsdriver.log file where the Grid Node runs. This happens when the log file is around 600MB in size. Obviously this causes my nodes to become unusable after some time.

Right now, I am creating my PhantomJS remote WebDriver in the following way:

public static IWebDriver CreatePhantomGridDriver(string hubAddress)
{
    if (hubAddress == null)
    {
        throw new ArgumentException(nameof(hubAddress));
    }

    PhantomJSOptions opts = new PhantomJSOptions();
    opts.AddAdditionalCapability("phantomjs.page.settings.userAgent", "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36");

    RemoteWebDriver driver = new RemoteWebDriver(new Uri(hubAddress), opts.ToCapabilities());

    driver.Manage().Timeouts().SetPageLoadTimeout(new TimeSpan(0, 1, 0));
    driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 1));
    return driver;
}

I am using selenium-server-standalone-2.52.0 for my Grid, and it has 2 nodes registered, each exposing 8 PhantomJS drivers: java -jar selenium-server-standalone-2.52.0.jar -role node -hub http://MySeleniumGridHubServer:4444/grid/register -port 5556 -browser browserName=phantomjs,version=1.9.8.0,platform=ANY,maxInstances=8 -timeout 60 -maxSession 100

If there is some way that I can disable the phantomjsdriver.log file at the time that I start the node via command line, that would be ideal!

Additionally, there seem to be a number of features exposed by PhantomJSOptions and the PhantomJSDriverService classes, but they don't seem to be able to be used together to create a driver instance, and both expose a different set of properties!

Thanks

0 Answers
Related