MinkSelenium2Driver icon indicating copy to clipboard operation
MinkSelenium2Driver copied to clipboard

Webdriver unknown error : evaluate.js is not loading

Open deepakmanhas-srijan opened this issue 10 years ago • 16 comments

I'm facing this error while executing the following steps in the feature :

@javascript
Feature: As an admin I want to add content to 
         Movies content type using different 
         fields
Background:
Given I am on "/user/login"
When  I login as "admin" with password "password"

Scenario: Successfull submission of Movies form by filling in required fields
Given I am on "/node/add/movies"
When I fill in the following:
| title | <title-text> |
And I click "edit-field-posters-und-0-browse-button"
And I switch to frame "mediaBrowser"
When I attach the file "image-path" to "edit-upload-upload"
And I press "Next"
And I press "Save"----- Error on/after this step------------
And I fill in the following:
| Custom Marketing Message | Latest movie of the batman series |
And I fill in the following:
 | edit-field-release-date-und-0-value-datepicker-popup-0 | 05/28/2014 |
And I click "switch_edit-body-und-0-value"
And I fill in the following:
 | edit-body-und-0-value | Batman movie part 4 , Batman gotham city |
And I fill in the following:
    | edit-field-asset-title-und-0-value | Batman |
And I select "value" from "Site Selection"
And I select "Action" from "Genre"
Then I press "edit-submit"
And I should see "Content has been created"

I'm getting the following error after the Save step.

 [WebDriver\Exception\UnknownError]

 Exception has been thrown in "afterStep" hook, defined in FeatureContext::afte
JavascriptStep()

 waiting for evaluate.js load failed
 Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03
 System info: host: 'Windows7-PC', os.name: 'Windows 7',
os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_45'
 Driver info: driver.version: unknown

deepakmanhas-srijan avatar Jun 17 '14 11:06 deepakmanhas-srijan

how does your afterStep hook look like ?

stof avatar Jun 17 '14 11:06 stof

This is the exception trace.

Exception trace:

 () at ...\vendor\instaclick\php-webdriver\lib\WebDriver\Exception.php:157
 WebDriver\Exception::factory() at ...\vendor\instaclick\php-webdriver\lib\WebDriver\AbstractWebDriver.php:140
 WebDriver\AbstractWebDriver->curl() at ...\vendor\instaclick\php-webdriver\lib\WebDriver\AbstractWebDriver.php:200
 WebDriver\AbstractWebDriver->__call() at ...\vendor\instaclick\php-webdriver\lib\WebDriver\Container.php:218
 WebDriver\Container->__call() at ...\vendor\behat\mink-selenium2-driver\src\Behat\Mink\Driver\Selenium2Driver.php:934
 WebDriver\Session->execute() at ...\vendor\behat\mink-selenium2-driver\src\Behat\Mink\Driver\Selenium2Driver.php:934
 Behat\Mink\Driver\Selenium2Driver->wait() at ...\vendor\behat\mink\src\Behat\Mink\Session.php:290
 Behat\Mink\Session->wait() at ...\vendor\drupal\drupal-extension\src\Drupal\DrupalExtension\Context\DrupalContext.php:435
 Drupal\DrupalExtension\Context\DrupalContext->iWaitForAjaxToFinish() at ...\vendor\drupal\drupal-extension\src\Drupal\DrupalExtension\Context\DrupalContext.php:425
 Drupal\DrupalExtension\Context\DrupalContext->afterJavascriptStep() at n/a:n/a call_user_func() at ...\vendor\behat\behat\src\Behat\Behat\Hook\Annotation\StepHook.php:61
 Behat\Behat\Hook\Annotation\StepHook->run() at ...\vendor\behat\behat\src\Behat\Behat\Hook\HookDispatcher.php:276
 Behat\Behat\Hook\HookDispatcher->fireHooks() at ...\vendor\behat\behat\src\Behat\Behat\Hook\HookDispatcher.php:222
 Behat\Behat\Hook\HookDispatcher->afterStep() at n/a:n/a call_user_func() at ...\vendor\symfony\event-dispatcher\Symfony\Component\EventDispatcher\EventDispatcher.php:164
 Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() at ...\vendor\symfony\event-dispatcher\Symfony\Component\EventDispatcher\EventDispatcher.php:53
 Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at ...\vendor\behat\behat\src\Behat\Behat\Tester\StepTester.php:96
 Behat\Behat\Tester\StepTester->visit() at ...\vendor\behat\gherkin\src\Behat\Gherkin\Node\AbstractNode.php:42
 Behat\Gherkin\Node\AbstractNode->accept() at ...\vendor\behat\behat\src\Behat\Behat\Tester\ScenarioTester.php:148
 Behat\Behat\Tester\ScenarioTester->visitStep() at ...\vendor\behat\behat\src\Behat\Behat\Tester\ScenarioTester.php:87
 Behat\Behat\Tester\ScenarioTester->visit() at ...\vendor\behat\gherkin\src\Behat\Gherkin\Node\AbstractNode.php:42
 Behat\Gherkin\Node\AbstractNode->accept() at ...\vendor\behat\behat\src\Behat\Behat\Tester\FeatureTester.php:88
 Behat\Behat\Tester\FeatureTester->visit() at ...\vendor\behat\gherkin\src\Behat\Gherkin\Node\AbstractNode.php:42
 Behat\Gherkin\Node\AbstractNode->accept() at ...\vendor\behat\behat\src\Behat\Behat\Console\Command\BehatCommand.php:150
 Behat\Behat\Console\Command\BehatCommand->runFeatures() at ...\vendor\behat\behat\src\Behat\Behat\Console\Command\BehatCommand.php:128
 Behat\Behat\Console\Command\BehatCommand->execute() at ...\vendor\symfony\console\Symfony\Component\Console\Command\Command.php:241
 Symfony\Component\Console\Command\Command->run() at ...\vendor\symfony\console\Symfony\Component\Console\Application.php:892
 Symfony\Component\Console\Application->doRunCommand() at ...\vendor\symfony\console\Symfony\Component\Console\Application.php:191
 Symfony\Component\Console\Application->doRun() at ...\vendor\behat\behat\src\Behat\Behat\Console\BehatApplication.php:68
 Behat\Behat\Console\BehatApplication->doRun() at ...\vendor\symfony\console\Symfony\Component\Console\Application.php:121
 Symfony\Component\Console\Application->run() at ...\bin\behat:32

deepakmanhas-srijan avatar Jun 17 '14 12:06 deepakmanhas-srijan

I was not asking for the exception trace, but for the code of the hook in which the exception happens

stof avatar Jun 17 '14 12:06 stof

  /**
   * For javascript enabled scenarios, always wait for AJAX after clicking.
   *
   * @AfterStep @javascript
   */
  public function afterJavascriptStep($event) {
    $text = $event->getStep()->getText();
    if (preg_match('/(follow|press|click|submit)/i', $text)) {
      $this->iWaitForAjaxToFinish();
    }
  }

deepakmanhas-srijan avatar Jun 17 '14 12:06 deepakmanhas-srijan

I've added some formatting to your comments @deepaknik123 if you don't mind, to make them easier to read.

aik099 avatar Jun 17 '14 12:06 aik099

There might be 2 problems, according to http://stackoverflow.com/questions/18114544/seleniumwebdrivererrorjavascripterror-waiting-for-evaluate-js-load-failed :

  1. malformed JavaScript execution
  2. old Selenium server version usage

Can you please post the actual JavaScript being executed?

aik099 avatar Jun 17 '14 12:06 aik099

@aik099 Thanks man! for the formatting. I'm using latest selenium standalone jar i.e 2.42.2 . Although I tried with some older versions also. While searching I found this link : https://github.com/Codeception/Codeception/issues/474 , not related to behat but its the same issue in other framework.

deepakmanhas-srijan avatar Jun 17 '14 12:06 deepakmanhas-srijan

Based on issue you've posted it might be a bug in the used instaclick/php-webdriver package version. The versions after 1.0.16 (according to https://github.com/Codeception/Codeception/issues/474#issuecomment-22332617) should be safe to you.

What version are you using? Listing the actually used versions of all composer packages on a project would be great help as well.

aik099 avatar Jun 17 '14 12:06 aik099

I'm trying to upload an image in the image upload field which is in the iframe. After uploading the image there are two button "Next" and "Save". After clicking on "Save" the iframe pop-up closes and after that the content form becomes unresponsive and throws the evaluate.js not loading error.

deepakmanhas-srijan avatar Jun 17 '14 12:06 deepakmanhas-srijan

To me that looks like a JS on the Save button is owned by iframe, which is closed by that button and that ends up in JS being executed without real context. I guess such complex stuff Selenium can't handle.

In general this is a problem too, because the function that you call after Save button press should be defined on main page and called from within iframe. This way is safer and Selenium might also be happy.

aik099 avatar Jun 17 '14 13:06 aik099

Sometimes the form is submitting successfully but once in many executions of the feature.

deepakmanhas-srijan avatar Jun 17 '14 13:06 deepakmanhas-srijan

This only proves my suspect. Sometimes iframe closes fast enough to kill JS in the middle of execution and that creates an error.

aik099 avatar Jun 17 '14 13:06 aik099

Is there any way to handle this situation ?

deepakmanhas-srijan avatar Jun 17 '14 13:06 deepakmanhas-srijan

As I said it's the problem in your application JavaScript code, not on Behat/Mink/Selenium side.

Can you change your application code as I proposed (move JS from iFrame to main page)?

aik099 avatar Jun 17 '14 13:06 aik099

Its a drupal application and the module being used for image upload is contributed by drupal community. So we can't change the code anyway.

deepakmanhas-srijan avatar Jun 17 '14 13:06 deepakmanhas-srijan

Then I'm out of ideas. You can debug the actual scenario and see what happens on a page as you execute steps. Maybe even enable JavaScript debugger (in browser). Then you'll be able to figure out the problematic code and figure out what workaround can be on your side (outside of iframe) to solve it.

Then submit a fix to Drupal community, because surely somebody gets same problem while using the app as you when you test it.

aik099 avatar Jun 17 '14 14:06 aik099