Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

reubenmiller
Copy link
Collaborator

@reubenmiller reubenmiller commented Oct 25, 2017

Adding support for setting nested iframes (i.e. as an array) to the WebDriverIO.

The application that I am testing makes heavy use of iframes, and overall WebDriverIO handles iframes better than Nightmare (though more on that later).

Summary

  • Within block now accepts nested frames when using the WebDriverIO Helper. Previously only the Nightmare Helper was supported.
  • Changed the default window size for the Helper tests because the tab tests were failing because the clickable element was "off screen"
  • Fixed acceptance test cases which were failing in the Nightmare Helper because Nightmare has problems if the any further navigation (i.e. clicking on a link) is done from within an iframe.

Example

Here is the example Scenario taken out of the ./test/acceptance/within_test.js which shows the usage.

Scenario('within on nested iframe (depth=2) and mixed id and xpath selector @WebDriverIO', (I) => {
  I.amOnPage('/iframe_nested');
  within({frame: ['#wrapperId', '[name=content]']}, () => {
    I.fillField('rus', 'Updated');
    I.click('Sign in!');
    I.see('Email Address');
  });
  I.see('Nested Iframe test');
  I.dontSee('Email Address');
});

Tests

The following tests were run after the changes and everything looks good.

  • WebDriverIO acceptance tests: node ./bin/codecept.js run -c ./test/acceptance/codecept.WebDriverIO.json --grep WebDriverIO
  • Nightmare acceptance: node ./bin/codecept.js run -c ./test/acceptance/codecept.Nightmare.json --grep nightmare
  • Core tests: npm tests
  • WebDriverIO tests: mocha test/helper/WebDriverIO_test.js
  • Nightmare tests: mocha test/helper/SeleniumWebdriver_test.js

Extra notes about iframes and Nightmare

The following works with WebDriverIO, but not with Nightmare. Nightware will say that it can not find the text Email Address, and it will print out the text of all elements from the iframe page before the I.click('Sign in!') was executed.

Scenario('within on iframe @WebDriverIO', (I) => {
  I.amOnPage('/iframe');
  within({frame: 'iframe'}, () => {
    I.fillField('rus', 'Updated');
    I.click('Sign in!');
    I.see('Email Address');
  });
  I.see('Iframe test');
  I.dontSee('Email Address');
});

I will chalk this up to a limitation with Nightmare and not due to my code changes since these tests were already failing when I made my fork.

P.S. This is my first pull request, so just let me know if I need to change something to get it into the 'standard' pull request format.

@reubenmiller
Copy link
Collaborator Author

The Travis’s build is currently failing due to being unresponsive for 10 mins.

Here is the excert from the Travis log.
selenium/standalone-chrome No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
Could one of the maintainers (I.e. someone with write access) please trigger the build on this pull request again, one of the dependencies of the build was not being pulled in a timely manner for some reason.

@jploskonka
Copy link
Contributor

@renancouto Travis had issues with pulling images from DockerHub yesterday, more info here: https://www.traviscistatus.com/incidents/v4jnp6nkgzqx Looks like issue is still present when I'm writing this :<

@renancouto
Copy link
Contributor

🤔 @jploskonka maybe you meant @reubenmiller?

@DavertMik
Copy link
Contributor

DavertMik commented Oct 26, 2017

Thanks, this look awesome! Yeah, you are right Nightmare can be far less stable than WebDriverIO so this feature is really handy.
Let me restart Travis builds

@jploskonka
Copy link
Contributor

Ups, tab completion missclick, sorry :D
Anyway seems like Docker Hub is having issues with large images (in Codecept case it's selenium-chrome) more info here: docker/hub-feedback#1225 and also CircleCI reported the same problems https://status.circleci.com/incidents/bz6w2805ph3c so looks like we need to wait until it's resolved :<

@reubenmiller
Copy link
Collaborator Author

The Travis pull issue should be resolved now (https://status.docker.com/pages/incident/533c6539221ae15e3f000031/59f1da512cd214649ebc33b0)

@DavertMik
Copy link
Contributor

Yes, it did. Thanks for good PR

@DavertMik DavertMik merged commit c79bf35 into codeceptjs:master Oct 27, 2017
@jploskonka jploskonka mentioned this pull request Oct 27, 2017
9 tasks
rlewan pushed a commit to rlewan/CodeceptJS that referenced this pull request Oct 30, 2017
* [WebDriverIO] Added support for nested iframes in the within block

* Added the @Nightmare tags to the extended nested iframe tests

* Modified default window size because the a few tab tests were failing because the clickable element was not visible.

* Added acceptance tests for the within feature for both WebDriverIO and Nightmare

* Updated expected window height in webapi tests due to changing it in a previous commit

* Fixed initial window size in the SeleniumWebdriver and Nightmare Helpers so it matches with the tests now

* Change the example with nested iframes in the docs so it shows the full use of within for the sake of consistency
@DavertMik
Copy link
Contributor

@reubenmiller , thanks again for sending this pull request. Please take a look at new Puppeteer helper. It can execute tests headlessly as Nightmare does but it has much cleaner API. Frames are first-class citizens there.
If you will have some time maybe you would help to implement frame support for within blocks in Puppeteer.

Maybe you will also consider Puppeteer to be a better alternative to Nightmare

@reubenmiller
Copy link
Collaborator Author

@DavertMik Yeah I might have some time over the holidays so I'll see what I can do.

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

Successfully merging this pull request may close these issues.

4 participants