How to Launch Apple Safari browser?

How to Launch Apple Safari browser?

Apple Safari

SafariDriver comes bundled with the Selenium server’s package, thus user is not required to download or set any external entity. It is readily available to execute the test scripts on Safari. Thus, user can directly launch the Safari Browser similar to that of Mozilla Firefox.

Example:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.safari.SafariDriver;
public class SafariDriverTest {

   public static void main(String[] args) {

       // Create webDriver reference
       WebDriver driver;
       // Launch SafariDriver
       driver = new SafariDriver();
       // Open the web page
       driver.get("http://google.com");
       // Enter the text in the search box
       WebElement searchText = driver.findElement(By.name("q"));
       searchText.sendKeys("SafariDriver");
       // Close the driver
       driver.quit();
   }
}

 

45total visits,1visits today

Leave a Reply

Your email address will not be published. Required fields are marked *