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


Java EventFiringWebDriver类代码示例

本文整理汇总了Java中org.openqa.selenium.support.events.EventFiringWebDriver的典型用法代码示例。如果您正苦于以下问题:Java EventFiringWebDriver类的具体用法?Java EventFiringWebDriver怎么用?Java EventFiringWebDriver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EventFiringWebDriver类属于org.openqa.selenium.support.events包,在下文中一共展示了EventFiringWebDriver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendXMLHttpGETRequest

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
public JsonElement sendXMLHttpGETRequest( final String url, final boolean async )
{
    ( ( EventFiringWebDriver ) driver ).manage().timeouts().setScriptTimeout( 20, TimeUnit.SECONDS );
    StrBuilder builder = new StrBuilder( "var callback = arguments[arguments.length - 1];\n" );
    builder.appendln( "var xhr = new XMLHttpRequest();" );
    builder.append( "xhr.open( 'GET', '" ).append( url ).append( "', '" ).append( async ).append( "' );" );
    builder.appendln( "xhr.onreadystatechange = function() { " );
    builder.appendln( "  if (xhr.readyState == 4) { " );
    builder.appendln( "    callback(xhr.responseText);" );
    builder.appendln( "  }" );
    builder.appendln( "}" );
    builder.appendln( "xhr.send();" );

    Object response = executeAsyncScript( builder.toString() );
    Gson gson = new Gson();
    return gson.fromJson( ( String ) response, JsonElement.class );
}
 
开发者ID:hemano,项目名称:cucumber-framework-java,代码行数:18,代码来源:JavaScriptHelper.java

示例2: before

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected void before() throws Throwable {
    DriverServiceFactory driverServiceFactory = drivertype.driverServiceFactory(configuration);
    service = driverServiceFactory.createService();

    log.info("starting service");
    service.start();

    driver = driverServiceFactory.createWebDriver(service);
    Preconditions.checkNotNull(driver,"driver should not be null after creation");

    if (!listeners.isEmpty()) {
        EventFiringWebDriver eventFiringWebDriver = new EventFiringWebDriver(driver);
        listeners.forEach(eventFiringWebDriver::register);
        driver = eventFiringWebDriver;
    }
}
 
开发者ID:lkwg82,项目名称:de.lgohlke.selenium-webdriver,代码行数:19,代码来源:DriverService.java

示例3: shouldBeWrappedInEventFiringWebdriver

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void shouldBeWrappedInEventFiringWebdriver() throws Throwable {
    AbstractWebDriverEventListener eventListener = new AbstractWebDriverEventListener() {
    };
    driverService = new DriverService(DriverType.PHANTOMJS, eventListener);

    driverService.before();

    WebDriver driver = driverService.getDriver();
    assertThat(driver).isInstanceOf(EventFiringWebDriver.class);

    EventFiringWebDriver eventFiringWebDriver = (EventFiringWebDriver) driver;
    Field                field                = EventFiringWebDriver.class.getDeclaredField("eventListeners");
    field.setAccessible(true);

    assertThat(((List<WebDriverEventListener>) field.get(eventFiringWebDriver)).size()).isEqualTo(1);
}
 
开发者ID:lkwg82,项目名称:de.lgohlke.selenium-webdriver,代码行数:19,代码来源:DriverServiceTest.java

示例4: DefaultSession

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
private DefaultSession(final DriverFactory factory, TemporaryFilesystem tempFs,
                       SessionId sessionId, final Capabilities capabilities) throws Exception {
  this.knownElements = new KnownElements();
  this.sessionId = sessionId;
  this.tempFs = tempFs;
  final BrowserCreator browserCreator = new BrowserCreator(factory, capabilities);
  final FutureTask<EventFiringWebDriver> webDriverFutureTask =
      new FutureTask<EventFiringWebDriver>(browserCreator);
  executor = new ThreadPoolExecutor(1, 1,
                                    600L, TimeUnit.SECONDS,
                                    new LinkedBlockingQueue<Runnable>());

  // Ensure that the browser is created on the single thread.
  EventFiringWebDriver initialDriver = execute(webDriverFutureTask);

  if (!isQuietModeEnabled(browserCreator, capabilities)) {
    // Memo to self; this is not a constructor escape of "this" - probably ;)
    initialDriver.register(new SnapshotScreenListener(this));
  }

  this.driver = initialDriver;
  this.capabilities = browserCreator.getCapabilityDescription();
  updateLastAccessTime();
}
 
开发者ID:alexkogon,项目名称:grid-refactor-remote-server,代码行数:25,代码来源:DefaultSession.java

示例5: configDriver

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
private WebDriver configDriver(WebDriver driver) {

		// Adding Web Event Listener
		if (eventFiring) {
			EventFiringWebDriver efirDriver = new EventFiringWebDriver(driver);
			WebEventListener driverListner = new WebEventListener();
			driver = efirDriver.register(driverListner);
		} else {
			log.warn(
					"FrameWork Wont Work Properly : 'Event Firing' Set To : '{}'",
					eventFiring);
		}

		if (fullscreen) {
			driver.manage().window().maximize();
		}

		driver.manage().timeouts().pageLoadTimeout(MAX_WAIT, TimeUnit.SECONDS);
		driver.manage().timeouts().implicitlyWait(MAX_WAIT, TimeUnit.SECONDS);
		return driver;
	}
 
开发者ID:adi4test,项目名称:WebAuto,代码行数:22,代码来源:ListenerHelper.java

示例6: isPresent

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
/**
 * Check if WebElement is present in the page Returns the boolean status
 * 
 * @param
 */
public synchronized boolean isPresent(By by) {
	log.trace("Is Present Element : {}", by);
	WebDriver driver = DriverManager.getDriver();
	WebDriver simpleDriver = driver;
	if (driver instanceof EventFiringWebDriver) {
		EventFiringWebDriver eventFirDriver = (EventFiringWebDriver) driver;
		simpleDriver = eventFirDriver.getWrappedDriver();
	}

	try {
		if (simpleDriver.findElements(by).size() > 0) {
			return true;
		}
	} catch (Exception e) {
		return false;
	}
	return false;
}
 
开发者ID:adi4test,项目名称:WebAuto,代码行数:24,代码来源:Element.java

示例7: getWebDriverInstance

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public WebDriver getWebDriverInstance() {
	WebDriver retVal = getWebDriver();
	if (null == retVal || !(((EventFiringWebDriver)retVal).getWrappedDriver() instanceof RemoteWebDriver)) {
		
		try {
			RemoteWebDriver remoteVal = new RemoteWebDriver(new URL(url), caps.get());
			remoteVal.setFileDetector(new LocalFileDetector());
			retVal = remoteVal;
		} catch (MalformedURLException e) {
			//TODO add handling for bad url
			e.printStackTrace();
		}
		
		setWebDriver(retVal);
	}
	return retVal;

}
 
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:23,代码来源:MyRemoteDriver.java

示例8: createFromEnvVar

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
/**
 * Create a WebDriver instance with useful settings based on the WEBDRIVER environment variable.
 * @return The WebDriver
 */
public static EventFiringWebDriver createFromEnvVar() {
    String browser = System.getenv(WEBDRIVER_ENV_NAME);
    if (browser == null) {
        log.info("WebDriver type not specified, defaulting to Chrome.");
        browser = "chrome";
    }

    switch (browser.toLowerCase()) {
        case "firefox":
            return createFirefox();

        default:
            log.warn("Unknown WebDriver type '{}', defaulting to Chrome.", browser);
        case "chrome":
            return createChrome();
    }
}
 
开发者ID:Lugribossk,项目名称:dropwizard-experiment,代码行数:22,代码来源:WebDriverFactory.java

示例9: callPostConstruct

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
private WebDriver callPostConstruct(D webDriverToBeChangedAfterConstruction) {
    webDriverConfigurationParticipantList
            .forEach(participant -> participant.postConstruct(webDriverToBeChangedAfterConstruction));
    EventFiringWebDriver eventFiringWebDriver = new EventFiringWebDriver(webDriverToBeChangedAfterConstruction);
    eventListeners.forEach(eventListener -> eventFiringWebDriver.register(eventListener));
    return eventFiringWebDriver;
}
 
开发者ID:willhaben,项目名称:willtest,代码行数:8,代码来源:AbstractSeleniumProvider.java

示例10: data

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
@Parameters(name = "{index}: {0} {1}")
public static Collection<Object[]> data() {
    return asList(new Object[][] {
            { SafariDriver.class, WebDriverException.class },
            { EventFiringWebDriver.class, InstantiationException.class },
            { HtmlUnitDriver.class, null },
            { RemoteWebDriver.class, IllegalAccessException.class } });
}
 
开发者ID:bonigarcia,项目名称:webdrivermanager,代码行数:9,代码来源:OtherWebDriverTest.java

示例11: beforeEachTest

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
@Before
public void beforeEachTest() throws IOException {
    tempFolder = testFolder.newFolder();
    driverPhantomJS = new EventFiringWebDriver(driverServicePhantomJS.getDriver())
            .register(new ErrorLoggingWebDriverEventListener(tempFolder.getPath()));
    chromeEventListener = new ErrorLoggingWebDriverEventListener(tempFolder.getPath());
    driverChrome = new EventFiringWebDriver(driverServiceChrome.getDriver())
            .register(chromeEventListener);
}
 
开发者ID:lkwg82,项目名称:de.lgohlke.selenium-webdriver,代码行数:10,代码来源:ErrorLoggingWebDriverEventListenerIT.java

示例12: call

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
public EventFiringWebDriver call() throws Exception {
  WebDriver rawDriver = factory.newInstance(capabilities);
  Capabilities actualCapabilities = capabilities;
  if (rawDriver instanceof HasCapabilities) {
    actualCapabilities = ((HasCapabilities) rawDriver).getCapabilities();
    isAndroid = actualCapabilities.getPlatform().is(Platform.ANDROID);
  }
  describedCapabilities = getDescription(rawDriver, actualCapabilities);
  return new EventFiringWebDriver(rawDriver);
}
 
开发者ID:alexkogon,项目名称:grid-refactor-remote-server,代码行数:11,代码来源:DefaultSession.java

示例13: enhance

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
@Override
public WebDriver enhance(WebDriver instance, Class<? extends Annotation> qualifier)
{
    //System.out.println("Adding AngularJS capabilities to WebDriver");
    instance.manage().timeouts().setScriptTimeout(2, TimeUnit.SECONDS);
    EventFiringWebDriver driver = new EventFiringWebDriver(instance);
    WebDriverEventListener listener = new AngularJSEventHandler();
    driver.register(listener);
    return driver;
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:11,代码来源:AngularJSDroneExtension.java

示例14: deenhance

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
@Override
public WebDriver deenhance(WebDriver enhancedInstance, Class<? extends Annotation> qualifier)
{
    if (EventFiringWebDriver.class.isInstance(enhancedInstance)) {
        //System.out.println("Removing AngularJS capabilities to WebDriver");
        EventFiringWebDriver driver = (EventFiringWebDriver) enhancedInstance;
        driver.unregister(listener);
        listener = null;
        return driver.getWrappedDriver();
    }
    return enhancedInstance;
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:13,代码来源:AngularJSDroneExtension.java

示例15: getDriver

import org.openqa.selenium.support.events.EventFiringWebDriver; //导入依赖的package包/类
/**
 * 如果当前进程没有绑定driver,创建一个然后绑定上,如果已经有了就直接返回
 * create a driver for this thread if not exist. or return it directly
 */
public static WebDriver getDriver(){
	WebDriver driver= DriverManager.ThreadDriver.get();
	if (driver==null){
		if (browserType.equals("firefox")){
			 driver = new EventFiringWebDriver(new FirefoxDriver()).register(new LogEventListener());
			 ThreadDriver.set(driver);
			//找东西前等三秒wait 3 second for every find by
		    DriverManager.getDriver().manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
		}
		//有需求的同学自己在这里添加IE等浏览器的支持
		//you can add ie/chrome or other driver here
		}
	return driver;
}
 
开发者ID:zhangting85,项目名称:simpleWebtest,代码行数:19,代码来源:TestCase.java


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