Skip to content

Find by javascript support and other improvements - #13

Merged
polosantiago merged 4 commits into
Nearsoft:masterfrom
andrewmackrodt:master
Oct 5, 2013
Merged

polosantiago merged 4 commits into
Nearsoft:masterfrom
andrewmackrodt:master

Conversation

@andrewmackrodt

Copy link
Copy Markdown
Contributor

Developers tend to have better familiarity with js selectors than xpath/css. I've extended the By class to include a jsSelector method which takes an optional second argument to specify how the lookup should be performed, e.g.

$driver->findElement(By:jsSelector('input[name^="en_"]')); # defaults to $
$driver->findElement(By:jsSelector('#content .red', 'document.querySelectorAll'));

It's also possible to speed up the running of unit tests by adjusting the environment variables introduced in phpunit.xml.dist (copy to phpunit.xml). The tests extend an abstract class which reset the browser state at the end of every test removing the need for the browser to be restarted between tests. Chrome's performance is several times faster than Firefox and I'm able to run the entire test suite in 45 seconds.

Changelog

Additions:

  • findElementsBy magic methods in WebDriver
  • environment variables to change the tests url and browser
  • an environment variable to specify tests should be run in a single browser instance (speed improvement)
  • innerHTML and outerHTML convenience methods in WebElement
  • find elements By user javascript selector
  • new tab hack in TargetLocator

Modifications:

  • Docblock and PhpStorm code inspection fixes
  • better timing precision in WebDriverWait->until
  • moved phpunit.xml to phpunit.xml.dist (and generate code coverage)

…gh Chrome

Additions:
  - findElementsBy magic methods in WebDriver
  - environment variables to change the tests url and browser
  - an environment variable to specify tests should be run in a single browser instance (speed improvement)
  - innerHTML and outerHTML convenience methods in WebElement
  - find elements By user javascript selector
  - new tab hack in TargetLocator

Modifications:
  - Docblock and PhpStorm code inspection fixes
  - better timing precision in WebDriverWait->until
  - moved phpunit.xml to phpunit.xml.dist (and generate code coverage)
…bDriver will convert WebElements to a usable type when calling executeScriptInternal.
…code duplication (added parent selector restriction to findElement(s)). Hacky support for jsSelector from a WebElement.
polosantiago pushed a commit that referenced this pull request Oct 5, 2013
@polosantiago
polosantiago merged commit d1681a6 into Nearsoft:master Oct 5, 2013
@polosantiago

Copy link
Copy Markdown
Contributor

Andrew,

Thanks for your valuable contributions, as I went through your edits, realized the good quality

@polosantiago

Copy link
Copy Markdown
Contributor

Internal tests run way more faster now with the single browser instance

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.

2 participants