use selenium
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://seleniumhq.org/')
use selenium
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://seleniumhq.org/')
why to use selenium
- Selenium is a set of libraries that help us automate and interact
with the browsers.
Why Selenium?
- OPEN SOURCE -> FREE
- It supports different types of browsers
- It supports multiple different programming languages
- Huge community behind it so many answers to any problems/questions
- Could run on different OS systems such as: Mac, Windows, Linux etc.
running Seleniam tests
// Sample test in Java to run Automate session.
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
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 JavaSample {
public static final String AUTOMATE_USERNAME = "YOUR_USERNAME";
public static final String AUTOMATE_ACCESS_KEY = "YOUR_ACCESS_KEY";
public static final String URL = "https://" + AUTOMATE_USERNAME + ":" + AUTOMATE_ACCESS_KEY + "@hub-cloud.browserstack.com/wd/hub";
public static void main(String[] args) throws Exception {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("os_version", "8");
caps.setCapability("resolution", "1920x1080");
caps.setCapability("browser", "Chrome");
caps.setCapability("browser_version", "latest-beta");
caps.setCapability("os", "Windows");
caps.setCapability("name", "BStack-[Java] Sample Test"); // test name
caps.setCapability("build", "BStack Build Number 1"); // CI/CD job or build name
WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
driver.get("https://www.google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("BrowserStack");
element.submit();
System.out.println(driver.getTitle());
driver.quit();
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us