use of org.openqa.selenium.htmlunit.HtmlUnitDriver in project cucumber-jvm by cucumber.
the class RentACarSupport method rentACar.
public void rentACar() {
WebDriver driver = new HtmlUnitDriver();
try {
driver.get(BASE_URL + "rent");
WebElement rentButton = driver.findElement(By.id("rentButton"));
rentButton.click();
} finally {
driver.close();
}
}
use of org.openqa.selenium.htmlunit.HtmlUnitDriver in project oxAuth by GluuFederation.
the class SelectAccountHttpTest method setUp.
@BeforeTest
public void setUp() {
driver = new HtmlUnitDriver(true);
pageConfig = newPageConfig(driver);
}
use of org.openqa.selenium.htmlunit.HtmlUnitDriver in project wechat by dllwh.
the class SinaWeiboCN method getSinaCookie.
/**
* ----------------------------------------------- [私有方法]
*/
/**
* @方法描述: 获取新浪微博的cookie,这个方法针对weibo.cn有效,对weibo.com无效
* weibo.cn以明文形式传输数据,请使用小号
* @param username
* 新浪微博用户名
* @param password
* 新浪微博密码
* @return
*/
public static String getSinaCookie(String username, String password) throws Exception {
HtmlUnitDriver driver = new HtmlUnitDriver();
driver.setJavascriptEnabled(true);
driver.get("http://login.weibo.cn/login/");
/**
* 手机号/电子邮箱/会员帐号:
*/
WebElement mobile = driver.findElementByCssSelector("input[name=mobile]");
mobile.sendKeys(new CharSequence[] { username });
/**
* 密码
*/
WebElement pass = driver.findElementByCssSelector("input[name^=password]");
pass.sendKeys(new CharSequence[] { password });
/**
* 图片验证码
*/
WebElement ele = driver.findElementByCssSelector("img");
String src = ele.getAttribute("src");
String cookie = concatCookie(driver);
HttpRequest request = new HttpRequest(src);
request.setCookie(cookie);
String imageCode = "";
WebElement code = driver.findElementByCssSelector("input[name^=code]");
code.sendKeys(new CharSequence[] { imageCode });
/**
* 记住登录状态,需支持并打开手机的cookie功能。
*/
WebElement rem = driver.findElementByCssSelector("input[name=remember]");
rem.click();
/**
* 登录按钮
*/
WebElement submit = driver.findElementByCssSelector("input[name=submit]");
submit.click();
String result = concatCookie(driver);
if (result.contains("gsid_CTandWM")) {
return result;
}
throw new Exception("weibo login failed");
}
use of org.openqa.selenium.htmlunit.HtmlUnitDriver in project saga by timurstrekalov.
the class InstrumentingProxyServerIT method setUp.
@Before
public void setUp() throws Exception {
final InstanceFieldPerPropertyConfig config = new InstanceFieldPerPropertyConfig();
proxyServer = new InstrumentingProxyServer(new HtmlUnitBasedScriptInstrumenter(config));
fileServer = new FileServer(new File(getClass().getResource("/tests").toURI()).getAbsolutePath());
proxyServerPort = proxyServer.start();
fileServerPort = fileServer.start();
final String proxyUrl = "localhost:" + proxyServerPort;
final Proxy proxy = new Proxy().setProxyType(Proxy.ProxyType.MANUAL).setHttpProxy(proxyUrl).setSslProxy(proxyUrl);
final DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(CapabilityType.PROXY, proxy);
desiredCapabilities.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT, true);
desiredCapabilities.setBrowserName(BrowserType.FIREFOX);
driver = new HtmlUnitDriver(desiredCapabilities) {
@Override
protected WebClient newWebClient(final BrowserVersion version) {
config.setBrowserVersion(version);
return WebClientFactory.newInstance(config);
}
};
}
use of org.openqa.selenium.htmlunit.HtmlUnitDriver in project oxAuth by GluuFederation.
the class BaseTest method initWebDriver.
protected WebDriver initWebDriver(boolean useNewDriver, boolean cleanupCookies) {
// Allow to run test in multi thread mode
HtmlUnitDriver currentDriver;
if (useNewDriver) {
currentDriver = new HtmlUnitDriver(true);
} else {
startSelenium();
currentDriver = driver;
if (cleanupCookies) {
System.out.println("authenticateResourceOwnerAndGrantAccess: Cleaning cookies");
deleteAllCookies();
}
}
return currentDriver;
}
Aggregations