2

I'm using Selenium with Mink to automatically register in a number of our websites.

To do that you have to select your birth date from three select inputs. I just use select-option with the xpath of the select field and the value of the option I want.

It works fine in Firefox and Chrome but in Safari, with some of the pages it works and with others nothing happens. There's no exception or anything, it just doesn't do anything with the select fields and then the rest of the test fails because the registration didn't work.

The CSS of the select fields is like this:

<select name="Signup:Birthday[day]" size="1" class=" date_day" id="Birthday">
<option value="" selected="selected">---</option>
<option value="1">01</option>
<option value="2">02</option>
<option value="3">03</option>
.......
</select>

I am using xpath //*[@id="Birthday"] and option 3 but in Safari it just does nothing.

public function selectState($option, $name) {
    $page          = $this->getSession()->getPage();
    $selectElement = $page->find('xpath', '//*[@id="Birthday"]');        
    $selectElement->selectOption($option);
}

Any ideas?

1
  • I am using xpath //*[@id="Birthday"] and option "3".. How do you use that? Share your code Commented Mar 3, 2017 at 9:49

1 Answer 1

1

You can try:

JavascriptExecutorUtils
    .setSelectedOptionByDisplayValue(driver, webSeleniumElement.getWebElement(), "texte");
JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
jsExecutor.executeScript("arguments[0].onchange();", webSeleniumElement.getWebElement());
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.