Mastering the process of running selenium automation scripts (written in Java) with Safari Technology Preview

Seeking assistance with running automation scripts on Safari.

Currently utilizing Selenium Webdriver scripts on Mac OS (High Sierra) and Safari 11.1.2

I've added the WebDriver Extension to the Safari browser and enabled 'Allow Remote Automation'

This is how I'm attempting to invoke Selenium Webdriver:

   SafariOptions safariOptions = new SafariOptions();
    safariOptions.useCleanSession(true);
    safariOptions.setUseTechnologyPreview(true);
    WebDriver driver = new SafariDriver(safariOptions);

I have Safari Technology Preview installed on my machine as well.

However, upon running the scripts, I encounter the following error:

    org.openqa.selenium.SessionNotCreatedException: Could not create a session: A browser with name 'safari' version '(null)' could not be found on the system.
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'Meghas-MacBook-Pro.local', ip: 'fe80:0:0:0:1c74:d309:2877:bd09%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_171'
Driver info: driver.version: InitiateWebDriver
remote stacktrace: 
    //stack trace details here...

Upon uninstalling Safari Technology Preview and changing the code to:

org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:24147
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'Meghas-MacBook-Pro.local', ip: 'fe80:0:0:0:1c74:d309:2877:bd09%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_171'
Driver info: driver.version: InitiateWebDriver
    //more details of the WebDriverException...

Additionally, it mentioned that "Safari driver requires safari 10 running on OSX EL Capitan or greater"

Answer №1

When using selenium webdrivers with Safari, it is important to specify the location of the Safari binary in order to run it successfully.

System.setProperty("webdriver.safari.driver", "/mypath/binary");

The typical path for the binary is

/System/Library/CoreServices/SafariSupport.bundle/Contents/MacOS/safaridriver
. Make sure to define this before implementing your example lines.

To enable Safari automation, click on the following link:

https://i.stack.imgur.com/eB0W4.png

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

When Jenkins is aborted during a build, it does not halt the execution of the Selenium tests

I am facing an issue with my Jenkins build configuration on my slave machine when running Selenium tests. If I abort the build during execution, Jenkins does not stop the execution properly and ChromeDriver continues to run for further tests. Is there a w ...

Adding Rust to an OpenJDK Docker image

I've been working on creating a dockerfile to run a rust test suite that needs a jar running on a separate port. I have the jar file stored in the project folder and plan to begin with an openjdk docker image, then download rust for testing purposes. ...

Tips on setting up shared functions in JMeter for scripts to utilize across various threads

Currently I am working with selenium and JMeter, and I have developed several groovy methods. However, a major obstacle I am encountering is the need to define these methods in each individual sampler. Is there a more efficient way to centrally store and ...

Retrieving information from embedded JavaScript code

The web page I am scraping contains inline JavaScript that dynamically generates telephone numbers inside a script tag. These numbers are not visible in the page source, making it challenging to scrape using common methods like x-path and beautiful soup. U ...

Ways to access an element in a Java ArrayList with two dimensions?

I recently converted a JSON string into a Java ArrayList and now I'm trying to retrieve a specific element from it. However, using .get(0).get(2) as an example doesn't seem to provide the desired result, as I discovered in another query. Upon u ...

Ensure that each page completely loads before proceeding in Selenium

I am currently working on a simple script that reads data from various pages. The code I have written so far is as follows: def parsePage (https): driver = webdriver.Chrome("path\chromedriver.exe") driver.get(https) content = driver.page_ ...

Element could not be found inside the pop-up dialog

I have been attempting to find those buttons displayed here: https://i.stack.imgur.com/5M1qd.png Here is the HTML for them: https://i.stack.imgur.com/238no.png I've experimented with different methods, but unfortunately, nothing has succeeded. ...

Exploring child elements of a By locator using Selenium in Java

I am working with an enum list of By locators for WebElements on a page. My goal is to select a specific option from a select box using a combination of the enum and additional information about the value I want to select. Is there a way to achieve this? U ...

Python selenium encountered a TimeoutException with the message "line 20" in the execution

from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait import time driver = webdriver.Firefox() driver.get("http://www.youtube.com") assert "YouTube" in driver.title def waiter(browser): elements = browser.find_element ...

The hub (Selenium 3.3) is continuously receiving registrations from the Selenium Grid Node

Executing this command on a virtual machine configures a node to connect with my Selenium Grid hub: java -Dwebdriver.ie.driver=C:\IEDriverServer.exe -Dwebdriver.chrome.driver=C:\chromedriver.exe -Dwebdriver.gecko.driver=C:\geckodriver0-15-0 ...

Accessing Selenium Server 3.0.1 with Perl integration

Has anyone else experienced issues with the perl module WWWW::Selenium not functioning correctly with Selenium server standalone 3.0.1? I'm wondering if there is a newer version available beyond 1.36. Selenium seems to recommend using this perl bindi ...

The elusive element remains out of reach for Selenium

I'm currently facing difficulty in accessing certain elements: <fieldset> <legend> Legend1 </legend> <table width=100%" cellspacing="3" bgcolor="white"> <tbody> <tr>...</tr> <tr&g ...

What is the best approach for handling @RequestParam in a JSP file?

Hello there! I have a query regarding the usage of @RequestParam in @RestController. My question is about extracting @RequestParam from the client side. Below is an example of server code using @RestController: @ResponseBody @RequestMapping(method = Reque ...

Unable to launch Chrome browser using Selenium WebDriver. Here is the code snippet I am using

I attempted to use the code below, however I did not achieve the desired outcome. Can someone please assist me with this? Code: System.setProperty("webdriver .chrome.driver","/var/lib/jenkins/workspace/ccs_func_test_build/ccs-cpw-automation-framework/../ ...

Is there a way to retrieve the background URL from CSS using Selenium Webdriver?

I am attempting to verify the URL of an image within a div element's background property in the CSS for the webpage. However, when I retrieve the CssValue and display it, it appears to be blank. The HTML structure for the div is as follows: <div ...

Python and Selenium scraping activity encountered captcha blocking on a website protected by DataDome security measures

I have been working on scraping car data from various websites using Selenium with Chrome browser. However, I've run into issues where some websites block Selenium with captcha validation after just 1 or 2 requests. One example of this is . I attempte ...

Require remote access to a Firefox browser on a connected machine through an open connection in a robot test case

Issue at hand: Attempting to run a Robothost Testcase which involves using the Open Connection keyword to connect to machineX and then utilizing the Open Browser keyword to open Firefox on machineX. However, instead of opening the Firefox browser on machin ...

RSelenium: Encounter issues with CSS selector while inputting search term

I am facing some difficulties while trying to initiate a search on this website. My goal is to first input a search query, followed by clicking the search button. Although I am successful in executing the second step, I seem to encounter issues when attemp ...

What is the best way to create a divider between tab panes in JavaFX?

I created a unique vertical tabpane, but I am struggling to insert horizontal lines between each label. Below is the code snippet I have used: .tab *.tab-label { -fx-rotate: 90; } .tab { -fx-padding: 3em 0.5em; } .tab-pane .tab-header-area .tab ...

Is there a way to access and read the console log of a specific website using Python code? I am looking to extract messages such as "ok" and "connected

Seeking guidance on how to interpret console log output for a specific website while automating with Python. Struggling to extract live console data through Selenium, as there's no built-in function for reading logs in real-time. Although I can acces ...