How to Run Selenium Tests on Safari using SafariDriver
On This Page Running Selenium Tests on Safari using SafariDriver How to Run Selenium Te
How to Run Selenium Tests on Safari habituate SafariDriver
Safari is the second well-nigh democratic browser in the macrocosm, occupying a 16 % grocery share, lay flop after Chrome. A key reason behind its significant market share is the fact that Safari is the default browser for all Apple device. Naturally, web-developers across the globe motive to ensure that their websites are thoroughly tested and optimize for all versions of Safari.
Overview
Why test in Safari?
- Safari holds a large share on macOS/iOS devices.
- Cross-browser reporting ensures accessibility for Apple user.
What is SafariDriver?
- SafariDriver is a WebDriver execution for Safari.
- It comes bundled by nonpayment with Safari 10 and supra.
How to set up?
- Enable “ Allow Remote Automation ” in Safari Develop card.
- Use webdriver.Safari () to initiate the driver in Selenium and run tests.
Limitations of Safari
- Windows does not support SafariDriver.
- Some advanced interactions may not be fully stable.
This article will discuss how to run Selenium tests on the Safari browser employ the SafariDriver.
For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.
Running Selenium Tests on Safari using SafariDriver
Prior to Safari automation, enable the Remote Automation feature from the developer menu. To do so, enable the Safari Developer menu first with the steps below:
- Go to Safari -> Preferences-> Advanced
- Tick mark the Checkbox with the label & # 8211;Show Develop cardin menu bar
Once done, go to the Develop carte and click on theAllow Remote Automationoption to enable it.
Once this is done, users can straightaway get started with the programming part without downloading Safari WebDriver.
This article assumes that the subscriber knows along with the required dependance or libraries. Let ’ s assume the use of for the upcoming representative.
Let ’ s consider a simple examination scenario with three steps:
- Launch Safari browser
- Visit https: //www.google.com
- Enter the hunt interrogation “ BrowserStack ”
- Click on the hunt push
- Close the browser
A Java program for the above test scenario is as follows:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; signification org.openqa.selenium.safari.SafariDriver; public class SafariDemo {public static void principal (String [] args) {// Instantiate a SafariDriver category. WebDriver driver = new SafariDriver (); // Launch Website driver.navigate () .to (`` http: //www.google.com/ ''); // Click on the search text box and send value driver.findElement (By.id (`` lst-ib '')) .sendKeys (`` BrowserStack ''); // Click on the hunting button driver.findElement (By.name (`` btnK '')) .click (); // Close the Browser driver.close ();}Executing the above code successfully will
- Launch the Safari browser
- Navigate to Google website
- Enter the search query as & # 8220; BrowserStack & # 8221; and
- Click on the search button
Also read:
Thus, Safari automation is achieved without explicitly downloading and pertain to a specific driver practicable as in the causa of Chrome and Firefox.
Exploring critical bugs faster is only possible when exam are executed on existent device. Testing teams or individual testers can use BrowserStack ’ s for running automatize Safari tests on iOS and macOS environments in parallel. As all the browsers are installed on actual Mac and iOS devices, teams are capable to test their site in, thus place every possible bug that can show up in the website ’ s real-world usage.
On This Page
# Ask-and-Contributeabout this topic with our Discord community.
Related Guides
Automate This With SUSA
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.
Try SUSA FreeTest Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free