本文整理汇总了Java中org.openqa.selenium.WebDriver.Options类的典型用法代码示例。如果您正苦于以下问题:Java Options类的具体用法?Java Options怎么用?Java Options使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Options类属于org.openqa.selenium.WebDriver包,在下文中一共展示了Options类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: close
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
/**
* 关闭浏览器引擎
*/
public void close()
{
if(driver != null)
{
Options manage = driver.manage();
boolean cookieSave = Boolean.parseBoolean(enginePro.getProperty("cookie.save", "false"));
File root = PathUtil.getRootDir();
File cookieFile = new File(root, enginePro.getProperty("cookie.save.path", "phoenix.autotest.cookie"));
if(cookieSave)
{
Set<Cookie> cookies = manage.getCookies();
try(ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream(cookieFile)))
{
output.writeObject(cookies);
}
catch (IOException e)
{
logger.error("", e);
}
}
driver.quit();
}
}
示例2: prepareDriver
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void prepareDriver() throws Exception {
System.clearProperty("test.selenium.remote");
localDriverClass = WebDriverMock.class.getName();
remoteDriverClass = WebDriverMock.class.getName();
scenario = "sc";
super.prepareDriver();
mockDriver = Mockito.mock(WebDriverMock.class);
Mockito.when(mockDriver.getScreenshotAs(ArgumentMatchers.any(OutputType.class)))
.thenReturn(new File(Thread.currentThread().getContextClassLoader().getResource("log4j2.json").toURI()));
final Options options = Mockito.mock(Options.class);
Mockito.when(options.window()).thenReturn(Mockito.mock(Window.class));
Mockito.when(mockDriver.manage()).thenReturn(options);
final WebElement webElement = Mockito.mock(WebElement.class);
Mockito.when(mockDriver.findElement(ArgumentMatchers.any(By.class))).thenReturn(webElement);
Mockito.when(webElement.isDisplayed()).thenReturn(true);
this.driver = mockDriver;
}
示例3: prepareDriver
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void prepareDriver() throws Exception {
testName = Mockito.mock(TestName.class);
Mockito.when(testName.getMethodName()).thenReturn("mockTest");
System.clearProperty("test.selenium.remote");
localDriverClass = WebDriverMock.class.getName();
remoteDriverClass = WebDriverMock.class.getName();
scenario = "sc";
super.prepareDriver();
mockDriver = Mockito.mock(WebDriverMock.class);
Mockito.when(((WebDriverMock) mockDriver).getScreenshotAs(ArgumentMatchers.any(OutputType.class))).thenReturn(
new File(Thread.currentThread().getContextClassLoader().getResource("log4j2.json").toURI()));
final Options options = Mockito.mock(Options.class);
Mockito.when(options.window()).thenReturn(Mockito.mock(Window.class));
Mockito.when(mockDriver.manage()).thenReturn(options);
final WebElement webElement = Mockito.mock(WebElement.class);
Mockito.when(mockDriver.findElement(ArgumentMatchers.any(By.class))).thenReturn(webElement);
Mockito.when(webElement.isDisplayed()).thenReturn(true);
this.driver = mockDriver;
}
示例4: prepareDriver
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void prepareDriver() throws Exception {
System.clearProperty("test.selenium.remote");
localDriverClass = WebDriverMock.class.getName();
remoteDriverClass = WebDriverMock.class.getName();
scenario = "sc";
super.prepareDriver();
mockDriver = Mockito.mock(WebDriverMock.class);
Mockito.when(mockDriver.getScreenshotAs(ArgumentMatchers.any(OutputType.class))).thenReturn(
new File(Thread.currentThread().getContextClassLoader().getResource("log4j2.json").toURI()));
final Options options = Mockito.mock(Options.class);
Mockito.when(options.window()).thenReturn(Mockito.mock(Window.class));
Mockito.when(mockDriver.manage()).thenReturn(options);
final WebElement webElement = Mockito.mock(WebElement.class);
Mockito.when(mockDriver.findElement(ArgumentMatchers.any(By.class))).thenReturn(webElement);
Mockito.when(webElement.isDisplayed()).thenReturn(true);
this.driver = mockDriver;
}
示例5: execute
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
/**
* 获取验证码
* @param engine 引擎
* @param param 例如:data,http://localhost:8080/G2/captcha!getLastCode.do
* @return 验证码
*/
public static String execute(SeleniumEngine engine, String param)
{
WebDriver driver = engine.getDriver();
Options manage = driver.manage();
String[] paramArray = param.split(",", 2);
if(paramArray.length != 2)
{
throw new RuntimeException("Param format is error, should be 'data,url'");
}
String key = paramArray[0];
String url = paramArray[1];
Set<Cookie> cookies = manage.getCookies();
List<AtCookie> atCookieList = new ArrayList<AtCookie>();
for(Cookie cookie : cookies)
{
String name = cookie.getName();
String value = cookie.getValue();
AtCookie atCookie = new AtCookie();
atCookie.setName(name);
atCookie.setValue(value);
atCookie.setPath(cookie.getPath());
atCookie.setDomain(cookie.getDomain());
atCookieList.add(atCookie);
}
String code = HttpApiUtil.getJsonValue(url, atCookieList, key);
return code;
}
示例6: mockWindow
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
private Window mockWindow() {
Options options = mock(Options.class);
doReturn(options).when(webDriver).manage();
Window window = mock(Window.class);
doReturn(window).when(options).window();
return window;
}
示例7: BaseATETest
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
/**
* Instantiates a new base ate test.
*/
public BaseATETest() {
super();
mockedDriver = ateMock(WebDriver.class);
myMockedDriver = ateMock(IMyWebDriver.class);
options = ateMock(Options.class);
TestProjectRunner.registerXsdNameSpaceParsers();
TestProjectRunner.registerProblemHandlers();
}
示例8: initData
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
@Before
public void initData() {
dataInitService.clear();
dataInitService.init();
webDriver = new PhantomJSDriver();
final Options options = webDriver.manage();
final Window window = options.window();
window.setSize(new Dimension(1280, 800));
}
示例9: shouldFindExistingCookie
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
@Test
public void shouldFindExistingCookie() {
WebDriver driver = mock(WebDriver.class);
Options options = mock(Options.class);
Cookie cookie = new Cookie(cookieName, "oki-doki");
when(driver.manage()).thenReturn(options);
when(options.getCookieNamed(eq(cookieName))).thenReturn(cookie);
assertThat("Cookie not found!", driver, hasCookie(cookieName));
}
示例10: shouldNotFindUnexistingCookie
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
@Test
public void shouldNotFindUnexistingCookie() {
final WebDriver driver = mock(WebDriver.class);
Options options = mock(Options.class);
when(driver.manage()).thenReturn(options);
when(options.getCookieNamed(eq(cookieName))).thenReturn(null);
assertThat("Cook should not be found", driver, not(hasCookie(cookieName)));
}
示例11: testWaitFixedTime
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
@Test
public void testWaitFixedTime() {
final Options options = mockDriver.manage();
Mockito.when(options.timeouts()).thenReturn(Mockito.mock(Timeouts.class));
waitFixedTime();
}
示例12: manage
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
/**
* Override this method to change {@link WebDriver} options before the test is run.
*/
@Override
public void manage( Options options ) {
options.window().setSize( new Dimension( 640, 480 ) );
}
示例13: getOptions
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
/**
* @return the options
*/
public Options getOptions() {
return options;
}
示例14: implicitWait
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
public static WebDriver implicitWait(WebDriver webDriver) {
Options webDriverOptions = webDriver.manage();
Timeouts timeouts = webDriverOptions.timeouts();
timeouts.implicitlyWait(30, TimeUnit.SECONDS);
return webDriver;
}
示例15: manage
import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
/**
* This life-cycle callback gives you a chance to modify {@link WebDriver} {@link Options} before
* the test starts.
*
* @param options {@link WebDriver} options.
*/
default void manage( Options options ) {}