Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webdriver unknown error : evaluate.js is not loading #163

Open
deepakmanhas-srijan opened this issue Jun 17, 2014 · 16 comments
Open

Webdriver unknown error : evaluate.js is not loading #163

deepakmanhas-srijan opened this issue Jun 17, 2014 · 16 comments

Comments

@deepakmanhas-srijan
Copy link

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
@stof
Copy link
Member

stof commented Jun 17, 2014

how does your afterStep hook look like ?

@deepakmanhas-srijan
Copy link
Author

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

@stof
Copy link
Member

stof commented Jun 17, 2014

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

@deepakmanhas-srijan
Copy link
Author

  /**
   * 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();
    }
  }

@aik099
Copy link
Member

aik099 commented Jun 17, 2014

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

@aik099
Copy link
Member

aik099 commented Jun 17, 2014

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?

@deepakmanhas-srijan
Copy link
Author

@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 : Codeception/Codeception#474 , not related to behat but its the same issue in other framework.

@aik099
Copy link
Member

aik099 commented Jun 17, 2014

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 Codeception/Codeception#474 (comment)) 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.

@deepakmanhas-srijan
Copy link
Author

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.

@aik099
Copy link
Member

aik099 commented Jun 17, 2014

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.

@deepakmanhas-srijan
Copy link
Author

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

@aik099
Copy link
Member

aik099 commented Jun 17, 2014

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

@deepakmanhas-srijan
Copy link
Author

Is there any way to handle this situation ?

@aik099
Copy link
Member

aik099 commented Jun 17, 2014

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)?

@deepakmanhas-srijan
Copy link
Author

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.

@aik099
Copy link
Member

aik099 commented Jun 17, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants