Created
February 10, 2021 22:24
-
-
Save Jaimin180296/6fef22b09d129c223aacb8e7d002667b to your computer and use it in GitHub Desktop.
Access Public
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 Assignment; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import org.openqa.selenium.remote.RemoteWebDriver; | |
import java.net.URL; | |
public class RunBehindProxy { | |
public static final String USERNAME = <userName>"; | |
public static final String AUTOMATE_KEY = "<accessKey>"; | |
public static final String URL = "http://" + USERNAME + ":" + AUTOMATE_KEY + "@hub-cloud.browserstack.com/wd/hub"; | |
public static void main(String[] args) throws Exception { | |
DesiredCapabilities caps = new DesiredCapabilities(); | |
caps.setCapability("browser", "Chrome"); | |
caps.setCapability("browser_version", "73.0"); | |
caps.setCapability("os", "Windows"); | |
caps.setCapability("os_version", "10"); | |
caps.setCapability("browserstack.networkLogs", "true"); | |
caps.setCapability("browserstack.local", "true"); | |
WebDriver driver = new RemoteWebDriver(new URL(URL), caps); | |
// Run as per use case | |
System.getProperties().put("http.proxyHost", "<HOST>"); | |
System.getProperties().put("http.proxyPort", "<PORT>"); | |
System.getProperties().put("http.proxyUser", "<USER>"); | |
System.getProperties().put("http.proxyPassword", "<PASSWORD>"); | |
System.getProperties().put("https.proxyHost", "<HOST>"); | |
System.getProperties().put("https.proxyPort", "<PORT>"); | |
System.getProperties().put("https.proxyUser", "<USER>"); | |
System.getProperties().put("https.proxyPassword", "<PASSWORD>"); | |
driver.get("https://www.browserstack.com/"); | |
WebElement element = driver.findElement(By.name("q")); | |
element.sendKeys("BrowserStack"); | |
element.submit(); | |
System.out.println(driver.getTitle()); | |
System.out.println(driver.getTitle()); | |
driver.quit(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment