WebPagetest Forums

Full Version: Page loads work with node.js agent, but WebDriver scripts don't
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been hitting my head against the wall, as I've tried everything and still can't get webdriver scripts to work. I have a local webpagetest server running on my OSX and is connected successfully to the test node.js agent (also running on the same OSX laptop).

Code:
node src/agent_main --serverUrl localhost --location Test --browser browser_local_chrome.BrowserLocalChrome --chromedriver /Users/kkrishnamurthy/funspace/webpagetest/agent/js/lib/webdriver/chromedriver/Darwin x86_64/chromedriver-2.4 --chrome /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
I Jan_16_18:11:31.353 browser_local_chrome.js:53 new BrowserLocalChrome : BrowserLocalChrome(/Users/kkrishnamurthy/funspace/webpagetest/agent/js/lib/webdriver/chromedriver/Darwin x86_64/chromedriver-2.4, /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
I Jan_16_18:11:31.369 wpt_client.js:373 Client.<anonymous> : Get work: http://localhost/work/getwork.php?location=Test&f=json

I tried firing up a test against a single URL from my local WPT instance and it works just as one would expect. BUT, when I try the same with the below WebDriver script fed into "Advanced Settings->Script", the node.js agent opens up the browser, but after that it just fails. Below is the script:

Code:
driver = new webdriver.Builder().build();
driver.get('http://www.google.com');
driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');
driver.findElement(webdriver.By.name('btnG')).click();
driver.wait(function() {
return driver.getTitle();
});

On the console, I see this:

Code:
I Jan_16_18:19:25.932 wpt_client.js:440 Client.processJobResponse_ : Got job: {"Test ID":"150117_T4_E","url":"script:\/\/150117_T4_E.pts","fvonly":1,"Capture Video":1,"runs":1,"browser":"Chrome","orientation":"default","script":"driver = new webdriver.Builder().build();\r\ndriver.get('http:\/\/www.google.com');\r\ndriver.findElement(webdriver.By.name('q')).sendKeys('webdri​ver');\r\ndriver.findElement(webdriver.By.name('btnG')).click();\r\ndriver.wait(​function() {\r\nreturn driver.getTitle();\r\n});"}
I Jan_16_18:19:25.944 agent_main.js:261 Agent.app_.schedule.addErrback.job.agentError : Starting run 1/1 of job 150117_T4_E
I Jan_16_18:19:26.186 browser_local_chrome.js:53 new BrowserLocalChrome : BrowserLocalChrome(/Users/kkrishnamurthy/funspace/webpagetest/agent/js/lib/webdriver/chromedriver/Darwin x86_64/chromedriver-2.4, /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
.I Jan_16_18:19:26.226 process_utils.js:355 unknown : Spawning: '/Users/kkrishnamurthy/funspace/webpagetest/agent/js/lib/webdriver/chromedriver/Darwin x86_64/chromedriver-2.4' '--port=4444'
I Jan_16_18:19:26.257 process_utils.js:358 Socket.<anonymous> : /Users/kkrishnamurthy/funspace/webpagetest/agent/js/lib/webdriver/chromedriver/Darwin x86_64/chromedriver-2.4 STDOUT: Starting ChromeDriver (v2.4.226086) on port 4444
I Jan_16_18:19:26.258 wd_server.js:221 WebDriverServer.<anonymous> : WD server URL: http://localhost:4444
I Jan_16_18:19:26.267 wd_server.js:224 WebDriverServer.<anonymous> : WD server is ready
I Jan_16_18:19:26.289 wd_server.js:1045 WebDriverServer.app_.schedule.addErrback.testError_ : Running user script
I Jan_16_18:19:26.306 wd_server.js:1047 WebDriverServer.app_.schedule.addErrback.testError_ : User script returned, but not necessarily finished
E Jan_16_18:19:46.526 wd_server.js:1049 WebDriverServer.<anonymous> : Script failed: unknown error: unable to discover open pages
  (Driver info: chromedriver=2.4.226086,platform=Mac OS X 10.9.3 x86_64)
E Jan_16_18:19:46.561 wd_server.js:1168 WebDriverServer.<anonymous> : Test failed: unknown error: unable to discover open pages
  (Driver info: chromedriver=2.4.226086,platform=Mac OS X 10.9.3 x86_64)
E Jan_16_18:19:46.583 wd_server.js:197 WebDriverServer.<anonymous> : Exception from "Done": UnknownError: unknown error: unable to discover open pages
  (Driver info: chromedriver=2.4.226086,platform=Mac OS X 10.9.3 x86_64)
E Jan_16_18:21:55.935 wpt_client.js:451 Client.abortJob_ : Aborting job 150117_T4_E: timeout
I Jan_16_18:22:00.981 agent_main.js:141 Agent.<anonymous> : wd_server child process exit code null signal SIGKILL
A Jan_16_18:22:01.137 wpt_client.js:554 Client.<anonymous> : Failed run 1/1 of finished job 150117_T4_E: timeout
I Jan_16_18:22:01.179 wpt_client.js:373 Client.<anonymous> : Get work: http://localhost/work/getwork.php?location=Test&f=json

What am I missing? Any help is appreciated.
I finally figured out that the reason my scripting fails is because of an outdated chromedriver. I upgraded to the latest one -- 2.13 and it worked like a charm!
Reference URL's