Skip to content

Instantly share code, notes, and snippets.

View barancev's full-sized avatar

Alexei Barantsev barancev

View GitHub Profile
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://rap.eclipsesource.com/workbenchdemo/rms");
driver.findElement(By.xpath("//div[text() = 'do it']")).click();
driver.findElement(By.xpath("//div[text() = 'Intro']")).click();
<html>
<body>
<select name="select" onblur="document.getElementById('blur').textContent='blur'">
<option value="1">test 1</option>
<option value="2">test 2</option>
<option value="3">test 3</option>
</select>
<p id="blur"></p>
</body>
</html>
<html>
<head>
<style type="text/css">
#invisible-with-children {
background-color:green;
height:100px;
width:100px;
overflow:hidden;
}
#invisible-parent {
public static void main(String[] args) throws Exception {
WebDriver driver = new FirefoxDriver();
driver.get("http://jasny.github.io/bootstrap/javascript.html#fileupload");
JavascriptExecutor jse = (JavascriptExecutor) driver;
WebElement navbar = driver.findElement(By.cssSelector(".navbar "));
jse.executeScript("arguments[0].style.display='none'", navbar);
WebElement fileinput=driver.findElement(By.cssSelector("#fileupload .bs-docs-example input[type='file']"));
jse.executeScript("arguments[0].style.opacity=1", fileinput);
jse.executeScript("arguments[0].style['transform']='translate(0px, 0px) scale(1)'", fileinput);
import java.io.File;
import java.io.FileOutputStream;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.*;
import org.browsermob.core.har.Har;
import org.browsermob.proxy.ProxyServer;
/* setters-style: */
// CommonOptions implements Options
CommonOptions commonOptions = new CommonOptions();
commonOptions.setProxy(...);
commonOptions.setOption("randomKey", "randomValue");
// FirefoxOptions implements Options
FirefoxOptions firefoxOptions = new FirefoxOptions();
import java.util.Arrays;
import java.util.List;
import java.util.Random;
public class Test {
public static void main(String[] args) {
List<String> stringList = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h");
String s = pickRandom(stringList);
WebDriver original = new FirefoxDriver();
SimpleUnhandledAlertHandler handler = new SimpleUnhandledAlertHandler();
UnhandledAlertHandlingWrapper wrapper = new UnhandledAlertHandlingWrapper(original);
wrapper.registerAlertHandler(handler);
WebDriver driver = wrapper.getDriver();
InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
.withLogLevel(InternetExplorerDriverLogLevel.TRACE)
.withLogFile(new File("iedriver.log"))
.build();
InternetExplorerDriver driver = new InternetExplorerDriver(service);
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference(FirefoxProfile.ALLOWED_HOSTS_PREFERENCE, "alias1,alias2");
WebDriver driver = new FirefoxDriver(profile);