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

selectOption - select option from different selector #3246

Closed
eXorus opened this Issue Jun 20, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@eXorus
Contributor

eXorus commented Jun 20, 2016

Hello,

Module : WebDriver
Version : 2.2.1
Browser : Firefox

<select id="select1">
<option value="select1_value1">Value1</option>
<option value="select1_value2">Value2</option>
</select>

<select id="select2">
<option value="select2_value1">Value1</option>
</select>
$I->selectOption('#select2', 'Value2');

Actual behaviour
The value "Value2" in field "#select1" is selected

Expected behaviour
Failed to select the value "Value2" because it is not in "#select2" field.

@eXorus

This comment has been minimized.

Show comment
Hide comment
@eXorus

eXorus Jun 20, 2016

Contributor

The issue is here in Module/WebDriver.php:selectOption() :

foreach ($option as $opt) {
    try {
        $optElement = $el->findElement(WebDriverBy::xpath('//option [contains (., "' . $opt . '")]'));
        $matched = true;
        if (!$optElement->isSelected()) {
        $optElement->click();
    }
    } catch (NoSuchElementException $e) {
        // exception treated at the end
    }
}

SelectOption doesn't care about the selector it take only the value to do the selection.

Contributor

eXorus commented Jun 20, 2016

The issue is here in Module/WebDriver.php:selectOption() :

foreach ($option as $opt) {
    try {
        $optElement = $el->findElement(WebDriverBy::xpath('//option [contains (., "' . $opt . '")]'));
        $matched = true;
        if (!$optElement->isSelected()) {
        $optElement->click();
    }
    } catch (NoSuchElementException $e) {
        // exception treated at the end
    }
}

SelectOption doesn't care about the selector it take only the value to do the selection.

@raistlin

This comment has been minimized.

Show comment
Hide comment
@raistlin

raistlin Jun 20, 2016

Member

@eXorus Please add some tests on your branch and submit a pull request.

Member

raistlin commented Jun 20, 2016

@eXorus Please add some tests on your branch and submit a pull request.

DavertMik added a commit that referenced this issue Jun 21, 2016

selectOption - select option from different selector (#3248)
* Fix issue #3246

* Add test testSelectInvalidOptionForSecondSelectFails

* Add html form

@eXorus eXorus closed this Jun 23, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment