

{"id":113952,"date":"2023-07-07T10:52:34","date_gmt":"2023-07-07T05:22:34","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=113952"},"modified":"2023-07-07T10:52:11","modified_gmt":"2023-07-07T05:22:11","slug":"running-test-on-safari","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/","title":{"rendered":"How to Run Selenium Tests on Safari?"},"content":{"rendered":"<p>Apple Inc. created the well-known web browser Safari, which is compatible with both Mac and Windows operating systems. Safari is known for its speed, security, and user-friendly interface. It is also a widely used browser among Apple users. In this article, we will discuss how to run Selenium tests on Safari.<\/p>\n<h3>How to Run Selenium Tests on Safari?<\/h3>\n<p>Below are the steps required to run Selenium Tests on Safari?<\/p>\n<h4>Step 1: Install the Safari WebDriver Extension<\/h4>\n<p>The first step in running Selenium tests on Safari is to install the Safari WebDriver Extension. The Safari WebDriver Extension is a plugin that allows Selenium to interact with the Safari browser. To install the extension, adhere to the procedures below.:<\/p>\n<p>a. Open Safari and go to the Develop menu.<\/p>\n<p>b. If the Develop menu is not visible, go to Safari Preferences &gt; Advanced and select the &#8220;Show Develop menu in the menu bar&#8221; option.<\/p>\n<p>c. From the Develop menu, select<strong> &#8220;Allow Remote Automation&#8221;.<\/strong><\/p>\n<p>d. Open the Terminal app on your Mac and type the following command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/usr\/bin\/ruby -e \"$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/master\/install)\"\r\n<\/pre>\n<p>This command will install Homebrew, a package manager for Mac.<\/p>\n<p>e. Once Homebrew is installed, type the following command to install the Selenium WebDriver for Safari:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">brew install selenium-server-standalone<\/pre>\n<p>f. After the installation is complete, type the following command to start the Selenium WebDriver:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">selenium-server -p 4444<\/pre>\n<p>g. Now, download the Safari WebDriver extension from the Selenium website.<\/p>\n<p>h. Once the extension is downloaded, double-click on the downloaded file to install it.<\/p>\n<p>i. Once the extension is installed, close and reopen Safari.<\/p>\n<h4>Step 2: Create a Selenium Test Script<\/h4>\n<p>Once the Safari WebDriver Extension is installed, we can create a Selenium test script. Follow the steps below to create a simple Selenium test script:<\/p>\n<p>a. Open a text editor or an IDE such as Eclipse.<\/p>\n<p>b. Create a new Java file and name it &#8220;SafariTest&#8221;.<\/p>\n<p>c. The following code should be copied and pasted into the file:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import org.openqa.selenium.WebDriver;\r\nimport org.openqa.selenium.safari.SafariDriver;\r\n\r\npublic class SafariTest {\r\n\r\npublic static void main(String[] args) {\r\n\r\n\/\/ Create a new instance of SafariDriver\r\nWebDriver driver = new SafariDriver();\r\n\r\n\/\/ Navigate to a website\r\ndriver.get(\"https:\/\/www.example.com\");\r\n\r\n\/\/ Close the browser\r\ndriver.quit();\r\n}\r\n}<\/pre>\n<p>In the above code, we have imported the WebDriver and SafariDriver classes from the Selenium library. We have created an instance of the SafariDriver class, which launches the Safari browser. We have navigated to a website using the get() method of the WebDriver interface. Finally, we have closed the browser using the quit() method of the WebDriver interface.<\/p>\n<h4>Step 3: Run the Selenium Test<\/h4>\n<p>To run the Selenium test, follow the steps below:<\/p>\n<p>a. Right-click on the SafariTest class and select Run As &gt; Java Application.<\/p>\n<p>b. Eclipse will compile the code and launch Safari.<\/p>\n<p>c. Safari will navigate to the website specified in the script.<\/p>\n<p>d. Once the test is complete, the browser will close automatically.<\/p>\n<p>If the test runs successfully, you should see Safari launching and navigating to the specified website.<\/p>\n<h3>Tips and Best Practices to Run Selenium Tests on Safari Browser:<\/h3>\n<p>1. Always make sure that the Safari browser version matches the version of the Safari WebDriver you are using. Otherwise, you may face compatibility issues.<\/p>\n<p>2. Use the latest version of the Safari WebDriver available on the Selenium website to ensure maximum compatibility.<\/p>\n<p>3. Before running the Selenium test on Safari, make sure that no other instances of Safari are running on the system.<\/p>\n<p>4. If you face any issues while running the test, try restarting the Safari browser or your system.<\/p>\n<h3>Conclusion:<\/h3>\n<p>In this article, we have discussed how to run Selenium tests on the Safari browser. We have covered the installation process of the Safari WebDriver Extension and the steps to create a simple Selenium test script. We have also provided some tips and best practices to ensure a smooth testing experience.<\/p>\n<p>Running Selenium tests on Safari can be a bit tricky, especially for beginners. However, with the right tools and knowledge, it is a manageable task. Safari is a popular browser among Apple users. Being able to test on Safari can help ensure that your web application or website is working correctly on all platforms.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apple Inc. created the well-known web browser Safari, which is compatible with both Mac and Windows operating systems. Safari is known for its speed, security, and user-friendly interface. It is also a widely used&#46;&#46;&#46;<\/p>\n","protected":false},"author":581,"featured_media":113955,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22825],"tags":[27573],"class_list":["post-113952","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-selenium-tutorials","tag-run-selenium-tests-on-safari"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Run Selenium Tests on Safari? - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn how to run Selenium tests on the Safari browser. See installation process of Safari WebDriver Extension &amp; creating Selenium test script.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Run Selenium Tests on Safari? - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn how to run Selenium tests on the Safari browser. See installation process of Safari WebDriver Extension &amp; creating Selenium test script.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-07T05:22:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/04\/running-test-on-safari.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Run Selenium Tests on Safari? - DataFlair","description":"Learn how to run Selenium tests on the Safari browser. See installation process of Safari WebDriver Extension & creating Selenium test script.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/","og_locale":"en_US","og_type":"article","og_title":"How to Run Selenium Tests on Safari? - DataFlair","og_description":"Learn how to run Selenium tests on the Safari browser. See installation process of Safari WebDriver Extension & creating Selenium test script.","og_url":"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2023-07-07T05:22:34+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/04\/running-test-on-safari.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445"},"headline":"How to Run Selenium Tests on Safari?","datePublished":"2023-07-07T05:22:34+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/"},"wordCount":646,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/04\/running-test-on-safari.webp","keywords":["Run Selenium Tests on Safari"],"articleSection":["Selenium Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/running-test-on-safari\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/","url":"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/","name":"How to Run Selenium Tests on Safari? - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/04\/running-test-on-safari.webp","datePublished":"2023-07-07T05:22:34+00:00","description":"Learn how to run Selenium tests on the Safari browser. See installation process of Safari WebDriver Extension & creating Selenium test script.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/running-test-on-safari\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/04\/running-test-on-safari.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/04\/running-test-on-safari.webp","width":1200,"height":628,"caption":"running test on safari"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/running-test-on-safari\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Selenium Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/selenium-tutorials\/"},{"@type":"ListItem","position":3,"name":"How to Run Selenium Tests on Safari?"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam6\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/113952","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=113952"}],"version-history":[{"count":5,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/113952\/revisions"}],"predecessor-version":[{"id":115957,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/113952\/revisions\/115957"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/113955"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=113952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=113952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=113952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}