当前位置: 首页>>代码示例>>Java>>正文


Java Options类代码示例

本文整理汇总了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();
	}
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:29,代码来源:SeleniumEngine.java

示例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;
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:20,代码来源:TAbstractSeleniumTest.java

示例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;
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:22,代码来源:TAbstractParallelSeleniumTest.java

示例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;
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:20,代码来源:TAbstractRepeatableSeleniumTest.java

示例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;
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:42,代码来源:KaptchaInvoker.java

示例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;
}
 
开发者ID:testIT-WebTester,项目名称:webtester-core,代码行数:8,代码来源:WebDriverBrowserTest.java

示例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();
}
 
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:12,代码来源:BaseATETest.java

示例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));
}
 
开发者ID:ttwd80,项目名称:qir,代码行数:10,代码来源:AbstractWebITCase.java

示例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));
}
 
开发者ID:yandex-qatools,项目名称:matchers-java,代码行数:13,代码来源:HasCookieMatcherTest.java

示例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)));
}
 
开发者ID:yandex-qatools,项目名称:matchers-java,代码行数:12,代码来源:HasCookieMatcherTest.java

示例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();
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:7,代码来源:TAbstractSeleniumTest.java

示例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 ) );
}
 
开发者ID:lukelast,项目名称:jelenium,代码行数:8,代码来源:CustomizeWebDriverOptions.java

示例13: getOptions

import org.openqa.selenium.WebDriver.Options; //导入依赖的package包/类
/**
 * @return the options
 */
public Options getOptions() {
	return options;
}
 
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:7,代码来源:BaseATETest.java

示例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;
}
 
开发者ID:liferay,项目名称:liferay-blade-samples,代码行数:10,代码来源:BladeSampleFunctionalActionUtil.java

示例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 ) {}
 
开发者ID:lukelast,项目名称:jelenium,代码行数:8,代码来源:JeleniumTest.java


注:本文中的org.openqa.selenium.WebDriver.Options类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。