1

I am extensively using PHPUnit and selenium with the WebDriver-PHP library provided on the chibimagic.org github page. I have done well to get this automation working but I have stumbled across a problem but working around until I came to point where this problem is causing me not to be able to finish what I started automating.

If I have multiple select boxes on specific pages on a website that we test (that is actually a web application), I can only select the first select box and change its option but not the remainder select boxes that follow after it even if I am using get_element to select the correct select boxes individually, it selects only the first select box and no further. I will include the HTML page I am not able to select a select box with that is necessary for me to select in order to complete the transaction on that page.

I would like to note that this feature does work on other pages, but just certain webpages I am testing create this problem. I am not able to change the HTML code of this page because it is controlled and developed solely by another company. So changing the HTML will not be possible and I cannot see a difference between the pages where it can select multiple select boxes and where it is not able to select multiple select boxes successfully.

I use XPath, CSS and the standard selectors when using get_element and I use this for pages where they select the element with no problem, to eliminate any reason that cause you to think I am not coding it correctly. The coding is fine, the library is not doing something correctly in particular situations of HTML code.

Note: This is occurs on many pages that have multiple select boxes. Please refer the pasteit link to the samples of HTML.

The attached HTML documents: Problem sample HTMLs: CreateDriver.html - not able to select multiple select boxes (only selects the first select box) http://pastebin.com/zdhSJLh6

No problem sample HTMLs: TripScreen.html - able to select multiple select boxes http://pastebin.com/6JPAZZG3

1
  • I don't have time to fix at present, but please note external paste boards aren't ideal for this site. They are subject to link breakage, and we like to keep questions self-contained for readers' convenience. Thanks! Commented Aug 12, 2014 at 10:12

1 Answer 1

1

It is a bug in the library that only selects the option based on its value, like

//option[45]

If there are options with the same value in different select menus, then the option in the first select menu is selected, instead of the intended option in the other menu.

Change the select_value($value) function in Webdriver.php from

public function select_value($value) {
    $this->get_next_element("//option[@value=" . WebDriver::QuoteXPath($value) . "]")->select();
}

to

 public function select_value($value) {
    $options = $this->get_options();
    foreach ($options as $option) {
        if ($option->get_value() == $value) {
            $option->click();
            break;
        }
        else {
            continue;
        }
    }

}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.