I'm using Karate 1.1.0 and running tests that combine both driver and robot instances. The tests are passing locally, but fail intermittently when executed through Jenkins with the following error:
js failed:
>>>>
01: delay(20000).screenshot()
<<<<
org.graalvm.polyglot.PolyglotException: failed to get reply for: [id: 2052, sessionId: D9DA8BB2B46A340A64D04C96EDFC9231, method: Page.captureScreenshot]
- com.intuit.karate.driver.DevToolsDriver.sendAndWait(DevToolsDriver.java:161)
- com.intuit.karate.driver.DevToolsMessage.send(DevToolsMessage.java:213)
- com.intuit.karate.driver.DevToolsMessage.send(DevToolsMessage.java:209)
- com.intuit.karate.driver.DevToolsDriver.screenshot(DevToolsDriver.java:823)
- com.intuit.karate.driver.DevToolsDriver.screenshot(DevToolsDriver.java:801)
- com.intuit.karate.driver.Driver.screenshot(Driver.java:119)
- <js>.:program(Unnamed:1)
In this particular example screenshot() call is 'ambiguous', but I've also tried it like so driver.screenshot(), which didn't make a difference:
js failed:
>>>>
01: driver.screenshot()
<<<<
org.graalvm.polyglot.PolyglotException: failed to get reply for: [id: 1832, sessionId: F7B7D4210527DE4B28FD2B85ACF66638, method: Page.captureScreenshot]
- com.intuit.karate.driver.DevToolsDriver.sendAndWait(DevToolsDriver.java:161)
- com.intuit.karate.driver.DevToolsMessage.send(DevToolsMessage.java:213)
- com.intuit.karate.driver.DevToolsMessage.send(DevToolsMessage.java:209)
- com.intuit.karate.driver.DevToolsDriver.screenshot(DevToolsDriver.java:823)
- com.intuit.karate.driver.DevToolsDriver.screenshot(DevToolsDriver.java:801)
- com.intuit.karate.driver.Driver.screenshot(Driver.java:119)
- <js>.:program(Unnamed:1)
Chrome is not running in headless mode and in some runs screenshots get captured successfully. Some other things I tried are:
changed the window size (addOptions: ['--window-size=1920,1080']);
used screenshotFull();
increased timeout (timeout: 90000);
increased Java heap space.
Any help will be greatly appreciated.
Related
Below is the sample code which is suppoe to fail as the file path is invalid.
Scenario: test input
* driver "https://fineuploader.com/demos.html"
* print "performing file upload"
* input("[name='qqfile']","in valid path")
* print "done file upload"
I see the error on the console
12:03:27.773 [chromedriver_1584979407695] WARN com.intuit.karate.shell.Command - exit code was non-zero: 1 - [/Users/vxt82/Apps/chromedriver, --port=9515, --user-data-dir=/Users/vxt82/repo/bitbucket/xtaf-unified-framwork/target/chromedriver_1584979407695]
12:03:31.648 [ForkJoinPool-1-worker-3] INFO com.intuit.karate - [print] performing file upload
12:03:31.711 [ForkJoinPool-1-worker-3] WARN com.intuit.karate - http response code: 404, response: {"value":{"stacktrace":"0 chromedriver 0x0000000108d72e99 chromedriver + 3747481\n1 chromedriver 0x0000000108d074d3 chromedriver + 3306707\n2 chromedriver 0x0000000108a96fef chromedriver + 749551\n3 chromedriver 0x0000000108a03128 chromedriver + 143656\n4 chromedriver .... 0x00007fff767a040d thread_start + 13\n","error":"no such element","message":"no such element: Element_id length is invalid\n (Session info: chrome=78.0.3904.50)"}}, request: [method: POST, responseTime: 4.207512, body: {"text":"in valid path"}]
12:03:31.718 [ForkJoinPool-1-worker-3] INFO com.intuit.karate - [print] done file upload
I was expecting test to fail but surprisingly it's passing. I looked into documentation but did not find anything specific to this scenarios.
Is this is expected behaviour, or I am doing some mistake in understanding?
Karate's file upload (input()) works similar to Selenium WebDrivers sendkeys(). It just does setting the text without validating is it file type and a path, Which I think is ok and as per design. May be as suggested Peter assertion can help at some extent to confirm file upload works.
I have a long pipeline of Codeception acceptance test set up in Jenkins. Safari regularly throws an \ScriptTimeoutException when starting a test (every 14 - 23 browser start throws this error). This does not happen on the same test each time the pipeline is started.
The exception prints as:
[Facebook\Webdriver\Exception\ScriptTimeoutException]
Timed out awaiting response to command "maximizeWindow" after 30002 ms
(WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 30.01 seconds
Currently, the safari environmental variable in acceptance.suite.yml looks like this:
safari:
modules:
config:
WebDriver:
browser: 'safari'
window_size: 'maximize'
clear_cookies: true
restart: true
options:
cleanSession: true
I've tried setting an exact window size and removing the window_size option entirely. There did not appear to be any difference in the occurrence rate of this error.
Using Selenium server 2.53.1. Safari version 9.1.2. Jenkins version 2.16
Any ideas on who to reduce the number of times this is happening?
I have also got this error:
1) ListingRaceTestCest: Test events
Test tests/acceptance/ListingRaceTestCest.php:Login
[Facebook\WebDriver\Exception\TimeOutException]
Scenario Steps:
$I->waitForElementVisible(".rule-row-date",15)
$I->click("button#add-rule-btn")
$I->see("Configure payment rules")
$I->waitForElementVisible("#side-menu",15)
$I->pauseExecution()
$I->click("table#races-table tbody tr:first-child td:last-child button")
I have found a solution now and its working for me, try this hope it works for you!
ini_set('max_execution_time', 300); //300 seconds = 5 minutes
This is setting for dynamic time you can change it accordingly. Codeception provides the execution time facility approx 5 min then it will give timeout error.
This situation I got and now found the solution.
The full error message is:
Test(s) failed. OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:59662/session timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out
The line in my code where this is happening simply instances a new ChromeDriver instance:
CurrentDriver = new ChromeDriver(section["chromedriverfolder"]);
So my question is... why does a new ChromeDriver invokes the /session URL, and what could be causing it to fail?
I experienced this same error using Selenium.WebDriver.ChromeDriver v2.22 and Chrome v52.0.2743.116 m running on TeamCity 9.x. I was able to fix the problem by rolling back the version of Chrome running on the TeamCity agents to v51.
When examining the agent executing the test, there is a popup with error: "Chrome Automation extension has crashed. Click this balloon to reload the extension."
It seems like a bug with the latest version of Chrome and Selenium.WebDriver.ChromeDriver, but as of yet this is the only lead I've found
EDIT: The link to the ChromeDriver issue
EDIT2: The link to the resolution
I have the answer where ChromeDriver invokes the /session URL, but not to the second part why it is timing out. Please see if it can provide some lead to the debug process to find out the failure :
When we call new ChromeDriver()
It creates RemoteWebDriver in the constructor :
super(new DriverCommandExecutor(service), capabilities);
which ultimately goes to :
public RemoteWebDriver(CommandExecutor executor, Capabilities desiredCapabilities,
Capabilities requiredCapabilities) {
In this method we do startClient which basically does nothing in this particular case
After startClient we do :
startSession(desiredCapabilities, requiredCapabilities);
This method issues the request /session in the following line :
Response response = execute(DriverCommand.NEW_SESSION, parameters);
The DriverCommand.NEW_SESSION is set as newSession which is mapped to post /session in the Command Codec
defineCommand(NEW_SESSION, post("/session"));
I try to run grunt test, and Selenium exits without closing the browser. I am unable to see where the exception is coming from.
grunt test
Running "protractor_webdriver:start" (protractor_webdriver) task
Starting Selenium server
Started Selenium server: http://127.94.0.1:4444
Running "protractor:projecttest" (protractor) task
[10:16:33] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[10:16:33] I/launcher - Running 1 instances of WebDriver
Session created: count=1, browserName=chrome
......Exception thrown: Going to shut down the Selenium server
Shutting down Selenium server: http://127.94.0.1:4444
Shut down Selenium server: http://127.94.0.1:4444 (OKOK)
Fatal error: 10:16:45.529 WARN - Exception thrown
All of my tests are passing. I even added logs to prove the final test passes and exits without exception.
I tried to up my logging from "dots" to "progress" but it doesn't change anything. Any ideas?
I am looking to migrate my selenium RC tests to using PHPUnit 3.4.12 from PHPUnit 3.3.2.
The selenium test will fail with an exception of the following when I use assertTextPresent():
PHPUnit_Framework_Exception: Response from Selenium RC server for getLocation().
ERROR Server Exception: sessionId should not be null; has this session been started yet?.
For example:
public function testSending($browser)
{
...
$browser->click("send");
$browser->waitForPageToLoad("30000");
$browser->assertTextPresent("text");
}
Below is the selenium RC log (running on Windows):
15:40:19.676 INFO - Command request: isTextPresent[text, ] on session 153d03a123c42098711994f43c2db34
15:40:19.691 INFO - Got result: OK,false on session 153d023a123c42098711994f43cdb34
15:40:19.879 INFO - Command request: testComplete[, ] on session 153d023a123c4298711994f43c2db34
15:40:19.879 INFO - Killing Firefox...
15:40:20.269 INFO - Got result: OK on session 153d023a123c42098711994f43c2db34
15:40:20.472 INFO - Command request: getLocation[, ] on session null
15:40:20.472 ERROR - Exception running 'getLocation 'command on session null
java.lang.NullPointerException: sessionId should not be null; has this session been started yet?
As you can see, the test should have completed as indicated by the "Killing Firefox" bit, but it instead continued to do something else and triggered the getLocation[, ] command which caused the exception.
I have tried the same test with PHPUnit 3.3.2 which did not produce this problem - the test would happily end without the getLocation().
Any ideas?
Actually the problem is with setAutoStop() method - by default it's set to TRUE, so PHPUnit sends stop signal to Selenium RC prior to tearDown().
Add $this->setAutoStop(false); to your setUp() method and $this->stop(); to the end of tearDown().