Skip to content

Instantly share code, notes, and snippets.

@ckzgraphics
Created April 26, 2018 16:29
Show Gist options
  • Save ckzgraphics/0693f4bccc4ab62acbedd8d4197a3a82 to your computer and use it in GitHub Desktop.
Save ckzgraphics/0693f4bccc4ab62acbedd8d4197a3a82 to your computer and use it in GitHub Desktop.
Test MouseMoveTo Action on Firefox 59 with w3c on BrowserStack
import java.io.File;
import java.net.URL;
import java.util.Set;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
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.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Test_MoveToElement_FF_w3c {
public static void main(String[] args) {
System.out.println("Executing :: FF_mouseMoveTo_w3c");
String USERNAME = "<BROWSERSTACK_USERNAME>";
String AUTOMATE_KEY = "<BROWSERSTACK_PASSWORD>";
String HUB_URL = "https://" + USERNAME + ":" + AUTOMATE_KEY + "@hub-cloud.browserstack.com/wd/hub";
JavascriptExecutor js = null;
WebDriver webDriver = null;
ChromeOptions options = null;
WebDriverWait wait = null;
Actions act = null;
String AUT_URL = "https://www.w3schools.com/css/css_tooltip.asp";
URL URLObj = null;
DesiredCapabilities caps = null;
try {
URLObj = new URL(HUB_URL);
caps = new DesiredCapabilities();
caps.setCapability("os", "Windows");
caps.setCapability("os_version", "10");
caps.setCapability("browserName", "Firefox");
caps.setCapability("browserVersion", "59.0");
caps.setCapability("browserstack.geckodriver", "0.19.1");
caps.setCapability("project", "Test Run");
caps.setCapability("build", "Version 1 - TEST);
caps.setCapability("name", "Test: W3C_MouseMoveTo_FF");
caps.setCapability("browserstack.timezone", "UTC");
caps.setCapability("browserstack.debug", "true");
caps.setCapability("browserstack.video", "true");
caps.setCapability("browserstack.networkLogs", "true");]
webDriver = new RemoteWebDriver(URLObj, caps);
wait = new WebDriverWait(webDriver, 10000);
act = new Actions(webDriver);
js = (JavascriptExecutor)webDriver;
webDriver.manage().window().maximize();
Thread.sleep(4000);
webDriver.get(AUT_URL);
webDriver.manage().window().maximize();
System.out.println("TITLE :: " + webDriver.getTitle());
Capabilities cap = ((RemoteWebDriver) webDriver).getCapabilities();
String browserName = cap.getBrowserName().toLowerCase();
System.out.println("BROWSER NAME :: " + browserName);
String os = cap.getPlatform().toString();
System.out.println("OS :: " + os);
String v = cap.getVersion().toString();
System.out.println("VERSION :: " + v);
act.moveToElement(webDriver.findElement(By.xpath("//*[@id='main']/div[3]/div[2]/div"))).build().perform();
Thread.sleep(5000);
} catch (Exception e) {
e.printStackTrace();
} finally {
if(webDriver != null){
webDriver.quit();
} // IF END
} // FINALLY END
} // MAIN END
} // CLASS END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment