minkphp / minkphp/Mink

Implement cross-driver $element->executeJs()

Open
#499 14 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature proposal response-needed
Dominant language
PHP
Stars
1.6k
Forks
286
PR merge metrics
No merged PRs in 30d

Description

I've found myself in a corner more than once, trying to use the built in search traversal with JS methods.

One example of that would be interacting with <select> augmenting JS scripts (selectable, select2 etc.). In order to work around issues with those, I need to be able to invoke pieces of JS on some elements.

For example:

// [...] find the field to change
$field->selectOption($option, false);
$this->getSession()->evaluateScript('$("select").trigger("change");');

Currently there's no easy method to get reference to the NodeElement node in JS. Internally, Selenium2 driver uses executeJsOnXpath() method which takes a script template and "injects" the element we want to target. I'd love to be able to do this:

// [...] find the field to change
$field->selectOption($option, false);
$field->executeJs('$({{ELEMENT}}).trigger("change");');

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing NodeElement and the Selenium2 driver's executeJsOnXpath() method, then review how the session's evaluateScript() is used. Implement the cross-driver element execution API so the target element can be referenced in the script, and verify the select-option change-event example works across supported drivers.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.