To run a test remotely at browserstack.com, here is their demo code with a few modifications for the maven/junit format:
import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import java.net.URL; import org.junit.*; import org.openqa.selenium.*; import com.codeborne.selenide.*; import static com.codeborne.selenide.Selenide.*; import static com.codeborne.selenide.CollectionCondition.*; import static com.codeborne.selenide.Condition.*; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class browserstackTest{ public static final String USERNAME = "yourname"; public static final String AUTOMATE_KEY = "yourkey"; public static final String URL = "https://" + USERNAME + ":" + AUTOMATE_KEY + "@hub-cloud.browserstack.com/wd/hub"; @Test public void main() throws Exception { DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability("browser", "Chrome"); caps.setCapability("browser_version", "62.0"); caps.setCapability("os", "Windows"); caps.setCapability("os_version", "10"); caps.setCapability("resolution", "1024x768"); caps.setCapability("browserstack.networkLogs", true); //browserstack.networkLogs=true; WebDriver driver = new RemoteWebDriver(new URL(URL), caps); driver.get("http://www.google.com"); WebElement element = driver.findElement(By.name("q")); element.sendKeys("BrowserStack"); element.submit(); System.out.println(driver.getTitle()); System.out.println("*************************************"); driver.quit(); } }
Browserstack automate offers videos of the selenium test, network logging (but it lengthens the test duration), and most of all -- detailed browser specification. This example specified Chrome on Windows 10 with a screen size of 1024x768. More info
0 Comments
Leave a Reply. |