Skip to content

Instantly share code, notes, and snippets.

@ckzgraphics
Created November 6, 2018 07:02
Show Gist options
  • Select an option

  • Save ckzgraphics/38ba378b40b1b8536ce0b1e2e0db054c to your computer and use it in GitHub Desktop.

Select an option

Save ckzgraphics/38ba378b40b1b8536ce0b1e2e0db054c to your computer and use it in GitHub Desktop.
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class GetLocationMojave {
public static void main(String[] args) {
String USERNAME = "<USERNAME>";
String AUTOMATE_KEY = "<ACCESS_KEY>";
String HUB_URL = "https://" + USERNAME + ":" + AUTOMATE_KEY + "@hub-euw.browserstack.com/wd/hub";
JavascriptExecutor js = null;
WebDriver webDriver = null;
ChromeOptions options = null;
Keys keys = null;
WebElement ele = null;
Actions act = null;
String AUT_URL = "https://www.whatsmybrowser.org/";
URL URLObj = null;
DesiredCapabilities caps = null;
try {
URLObj = new URL(HUB_URL);
caps = new DesiredCapabilities();
caps.setCapability("browserName", "Safari");
caps.setCapability("browserVersion", "12.0");
caps.setCapability("os", "OS X");
caps.setCapability("os_version", "Mojave");
caps.setCapability("project", "Test Run");
caps.setCapability("build", "Support Automate");
caps.setCapability("name", "Mojave Get Location Test");
caps.setCapability("browserstack.use_w3c", "true");
caps.setCapability("browserstack.selenium_version", "3.14.0");
webDriver = new RemoteWebDriver(URLObj, caps);
webDriver.get(AUT_URL);
webDriver.manage().timeouts().setScriptTimeout(120, TimeUnit.SECONDS);
System.out.println("TITLE :: " + webDriver.getTitle());
Thread.sleep(10000);
webDriver.findElement(By.xpath("//*[@id='header']/div/h1/a")).getLocation();
Thread.sleep(5000);
} catch (Exception e) {
e.printStackTrace();
} finally {
if(webDriver != null){
webDriver.quit();
}
}
}
} // CLASS END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment