Created
November 2, 2018 05:59
-
-
Save ckzgraphics/76547763b745dadc7ab738b3d77007fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.File; | |
| import java.net.URL; | |
| import java.util.HashMap; | |
| import java.util.Map; | |
| import org.openqa.selenium.OutputType; | |
| import org.openqa.selenium.TakesScreenshot; | |
| import org.openqa.selenium.WebDriver; | |
| import org.openqa.selenium.chrome.ChromeOptions; | |
| import org.openqa.selenium.remote.DesiredCapabilities; | |
| import org.openqa.selenium.remote.RemoteWebDriver; | |
| public class ChromeExtension_PlugIn_Test { | |
| public static void main(String[] args) { | |
| String USERNAME = "<USERNAME>"; | |
| String AUTOMATE_KEY = "<ACCESS_KEY>"; | |
| String HUB_URL = "https://" + USERNAME + ":" + AUTOMATE_KEY + "@hub-cloud.browserstack.com/wd/hub"; | |
| String AUT_URL = "https://www.whatsmybrowser.org/"; | |
| WebDriver webDriver = null; | |
| ChromeOptions options = null; | |
| URL URLObj = null; | |
| DesiredCapabilities caps = null; | |
| try { | |
| URLObj = new URL(HUB_URL); | |
| options = new ChromeOptions(); | |
| options.addExtensions(new File("/Users/test/Downloads/rooof-devel[6.84.10].crx")); | |
| caps = new DesiredCapabilities(); | |
| caps.setCapability(ChromeOptions.CAPABILITY, options); | |
| caps.setCapability("browser", "Chrome"); | |
| caps.setCapability("browser_version", "69.0"); | |
| caps.setCapability("os", "Windows"); | |
| caps.setCapability("os_version", "7"); | |
| caps.setCapability("project", "Test Run"); | |
| caps.setCapability("build", "Support Automate"); | |
| caps.setCapability("name", "Test: Extension - PlugIn"); | |
| caps.setCapability("acceptSslCerts", "true"); | |
| caps.setCapability("browserstack.debug", "true"); | |
| caps.setCapability("browserstack.console", "verbose"); | |
| caps.setCapability("browserstack.selenium_version", "3.11.0"); | |
| webDriver = new RemoteWebDriver(URLObj, caps); | |
| webDriver.manage().window().maximize(); | |
| webDriver.get(AUT_URL); | |
| Thread.sleep(10000); | |
| take_screenshot(webDriver); | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } finally { | |
| if(webDriver != null){ | |
| webDriver.quit(); | |
| } | |
| } | |
| } // MAIN END | |
| public static void take_screenshot(WebDriver webDriver){ | |
| try { | |
| TakesScreenshot scrShot =((TakesScreenshot)webDriver); | |
| File SrcFile=scrShot.getScreenshotAs(OutputType.FILE); | |
| // File DestFile=new File("/Users/test.png"); | |
| // FileUtils.copyFile(SrcFile, DestFile); | |
| } catch (Exception e) { | |
| // e.printStackTrace(); | |
| } | |
| } // FUNC END | |
| } // CLASS END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment