Created
June 7, 2019 16:45
-
-
Save ckzgraphics/660fbc0b086b504fd2ba3a7059f84f8a 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
package com.bs.test; | |
import java.io.File; | |
import java.net.URL; | |
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 DEBUG_ChromeExtension_PlugIn { | |
public static void main(String[] args) { | |
String USERNAME = "<BROWSERSTACK_USERNAME>"; | |
String AUTOMATE_KEY = "<BROWSERSTACK_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("/path/to/file/Custom.Right-Click.Menu.chrome.crx")); | |
// DOWNLOAD THE CRX- https://github.com/SanderRonde/CustomRightClickMenu/releases/tag/2.2.8 | |
caps = new DesiredCapabilities(); | |
caps.setCapability(ChromeOptions.CAPABILITY, options); | |
caps.setCapability("browser", "Chrome"); | |
caps.setCapability("browser_version", "74.0"); | |
caps.setCapability("os", "Windows"); | |
caps.setCapability("os_version", "10"); | |
caps.setCapability("project", "Test Run"); | |
caps.setCapability("build", "Build v1"); | |
caps.setCapability("name", "DEBUG: Extension - PlugIn Chrome 74"); | |
caps.setCapability("acceptSslCerts", "true"); | |
caps.setCapability("browserstack.debug", "true"); | |
caps.setCapability("browserstack.console", "verbose"); | |
caps.setCapability("browserstack.selenium_version", "3.14.0"); | |
webDriver = new RemoteWebDriver(URLObj, caps); | |
webDriver.get(AUT_URL); | |
Thread.sleep(5000); | |
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