Having issues selecting an option from a select input in Safari while using Selenium

Currently, I am utilizing Selenium in combination with Mink to automate the registration process on several of our websites.

In order to proceed with the registration, it is necessary to select your birth date from three different drop-down menus. My approach involves using the select-option method along with the XPath of the select field and the desired option value.

While this method functions properly in both Firefox and Chrome, I have encountered an issue with Safari. On certain pages, the selection process works as intended, yet on others, nothing happens. Strangely, there are no exceptions thrown; the script simply fails to interact with the select fields, resulting in a failed registration.

The structure of the select fields' CSS is as follows:

<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>

Even though I am employing the xpath //*[@id="Birthday"] along with option 3, Safari seems unresponsive.

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

Any suggestions or insights?

Answer №1

If you're looking to try something out, consider this approach:

Utilize the JavascriptExecutorUtils class to select an option by its display value with the driver and webSeleniumElement parameters. For example, you can use the setSelectedOptionByDisplayValue method passing in the driver, web element, and desired text.
JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
jsExecutor.executeScript("arguments[0].onchange();", webSeleniumElement.getWebElement());

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Transforming unprocessed unicode characters into readable text

Currently, I am using Python 3.8 along with Selenium to extract text from HTML sources. When I retrieve the page_source, the output appears as follows: html_source = browser.page_source print(html_source) >>> \u514d\u8cbb\u8cc7&bsol ...

Add an array to every item on the list using individual unordered lists

I need help with a JavaScript code that will add elements from an array to each list on my webpage. The goal is to add numbers 1 through 4 to the list items, but only up to the number of items in the array. If there are only three list items, I want the sc ...

The function sendKeys() is unable to transmit the "@" symbol

Utilizing selenium version 3.6.0, I executed a basic test (logging into the Stackoverflow page). However, when attempting to send an email, the "@" character is not being transmitted correctly. It seems like random values from the buffer are being input in ...

Resolving the transition effect problem in Tailwind CSS and Alpine JS

I have successfully implemented a basic button and modal combination using Tailwind and Alpine - check out the demo here: https://jsfiddle.net/0pso5cxh/ However, I am facing an issue with the leave transition. When the cancel button or close icon is click ...

Tips for personalizing the FileField in wtforms to function as an image button

I'm attempting to display an image from my project's directory as an icon instead of the standard "choose file" button. Unfortunately, my attempts thus far have been unsuccessful. Not only is the image not loading, but the original button is only ...

Why isn't the footer extending to the edges despite setting margins and other properties?

Feeling a bit lost here. My footer isn't extending to the edges of the window like it should, or so I thought. .footer { height: 200px; bottom: 0px; margin: 0px; left: 0px; right: 0px; padding: 0px; width: 100%; background-color: #E ...

Tips for breaking out of an infinite loop while loading HTML containing a carousel into a blank <div> within another HTML file using jQuery's $(document).ready() function

Currently, I am studying HTML, CSS, Bootstrap 4, jQuery3, and JavaScript (ES6+), and to enhance my skills, I have devised an exercise for practice and consolidation. I have created 4 HTML files, all featuring responsive design based on Bootstrap 4: inde ...

What could be causing this navigation item to vanish in Firefox?

Check out this link: http://jsfiddle.net/Nvntm/1/ In Firefox and some other browsers, the "Support" navigation item disappears while the other three remain. Why does this happen? Is there something incorrect in my code? ...

Tips for ensuring that each flexbox element fills up a single line

My goal is to have each child element fill up one line by itself. See this screenshot for reference: https://i.stack.imgur.com/F40Xm.png Below is the code I am currently using: main { display: flex; justify-content: space-around; align-items: ...

Adjust the CSS button size to match the HTML border dimensions

As I work on my website, I have created buttons and used CSS to adjust the padding in order to make them equal in size. However, I am now curious if there is a way to dynamically size the buttons to fit within the table border for a consistent look across ...

Is there a way to verify if my webpage has completely loaded using Selenium in C#?

Does anyone know how to verify that my webpage has fully loaded in Selenium with C# without using TestNG? If the page is not fully loaded, I don't want the test to fail. Instead, I'd like it to retry the same test case. I am working with MSTest r ...

What methods are available to load sections of a complex SVG shape asynchronously?

I'm currently in the process of creating a website with a geographic map built using SVG, pulling data from OpenStreetMap. Due to its large size and potential for transformations such as zooming and moving, only a portion of it will be visible on the ...

Create a scrollable div within a template

After discovering a template that I want to use for my personal project, I noticed a missing element... There's a div where content can be added. That's fine, but what if I add more content than fits in the space provided? The whole website beco ...

WebDriverException encountered: Description - Attempting to initiate a new session using GeckoDriver Firefox version 65 and Selenium using Python 3.7

I am attempting to utilize Python 3.7 along with Selenium, Geckodriver, and Firefox v65.0 for the purpose of web scraping. A new window opens, but unfortunately Firefox does not provide the correct response about the session to Python which ultimately resu ...

Dealing with changing elements using cucumber and capybara

(Click for image) I've been working on a project where I need to create a scenario to test the login feature. However, I've encountered an issue with Capybara not being able to access dynamic elements. To Reproduce the Issue: 1) Go to Redfin.co ...

Tips for choosing checkboxes that have a opacity of 0.5

Is there a way to target checkboxes with an opacity of 0.5? The selector :checkbox[style~='opacity: 0.5'] seems to be ineffective in selecting them. ...

Stopping a div from causing the parent table's width to increase

I've encountered an interesting challenge with a project I'm working on. I need to inject markup into pages that I don't have control over, specifically within tables. The issue arises when my injected div causes the parent table to expand u ...

Python error involving the StaleElementReferenceException exception in selenium common.exceptions

I encountered an issue while trying to run the following code snippet: from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait driver = webdriver.Firefox() driver.get("https://itunesconnect.apple.com/WebObjects/iTunesConne ...

Issue with Firefox when combining text-transform and text-overflow properties

Hope everything is going well. I encountered a challenging issue that I need help with (please run the snippet using firefox on Windows or Linux) : <html> <head> <style> .content { backgro ...

The issue encountered is a WebDriverException caused by the unexpected exit of the Google Chrome service at /usr/bin/google-chrome while using ChromeDriver with Selenium in a

from selenium import webdriver driver = webdriver.Chrome(executable_path=r'/usr/local/bin/google-chrome') driver.get('https://www.google.co.in') print("Page Title is : %s" %driver.title) driver.quit() I encountered the following error ...