本文整理汇总了Java中org.openqa.selenium.remote.LocalFileDetector类的典型用法代码示例。如果您正苦于以下问题:Java LocalFileDetector类的具体用法?Java LocalFileDetector怎么用?Java LocalFileDetector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LocalFileDetector类属于org.openqa.selenium.remote包,在下文中一共展示了LocalFileDetector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSauce
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的package包/类
protected static RemoteWebDriver createSauce ( final Platform os, final String browser, final String version ) throws MalformedURLException
{
final DesiredCapabilities capabilities = new DesiredCapabilities ();
capabilities.setBrowserName ( browser );
if ( version != null )
{
capabilities.setVersion ( version );
}
capabilities.setCapability ( CapabilityType.PLATFORM, os );
capabilities.setCapability ( CapabilityType.SUPPORTS_FINDING_BY_CSS, true );
capabilities.setCapability ( "name", "Eclipse Package Drone Main Test" );
if ( System.getenv ( "TRAVIS_JOB_NUMBER" ) != null )
{
capabilities.setCapability ( "tunnel-identifier", System.getenv ( "TRAVIS_JOB_NUMBER" ) );
capabilities.setCapability ( "build", System.getenv ( "TRAVIS_BUILD_NUMBER" ) );
capabilities.setCapability ( "tags", new String[] { "CI" } );
}
final RemoteWebDriver driver = new RemoteWebDriver ( new URL ( String.format ( "http://%s:%[email protected]%s/wd/hub", SAUCE_USER_NAME, SAUCE_ACCESS_KEY, SAUCE_URL ) ), capabilities );
driver.setFileDetector ( new LocalFileDetector () );
return driver;
}
示例2: createSauce
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的package包/类
protected static RemoteWebDriver createSauce ( final Platform os, final String browser, final String version ) throws MalformedURLException
{
final DesiredCapabilities capabilities = new DesiredCapabilities ();
capabilities.setCapability ( CapabilityType.BROWSER_NAME, browser );
if ( version != null )
{
capabilities.setCapability ( CapabilityType.VERSION, version );
}
capabilities.setCapability ( CapabilityType.PLATFORM, os );
capabilities.setCapability ( "name", "Package Drone Main Test" );
final RemoteWebDriver driver = new RemoteWebDriver ( new URL ( String.format ( "http://%s:%[email protected]:80/wd/hub", SAUCE_USER_NAME, SAUCE_ACCESS_KEY ) ), capabilities );
driver.setFileDetector ( new LocalFileDetector () );
return driver;
}
示例3: getWebDriverInstance
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的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;
}
示例4: uploadFile
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的package包/类
@Override
@Monitor
@RetryFailure(retryCount=3)
@JSHandle
public WebDriverController uploadFile(Object locator, String path) {
LocalFileDetector detector = new LocalFileDetector();
File localFile = detector.getLocalFile(path);
((RemoteWebElement)waitController().waitForElementPresence(locator)).setFileDetector(detector);
waitController().waitForElementPresence(locator).sendKeys(localFile.getAbsolutePath());
return this;
}
示例5: postConstruct
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的package包/类
@Override
public void postConstruct(D webDriver) {
if (webDriver instanceof RemoteWebDriver) {
try {
((RemoteWebDriver) webDriver).setFileDetector(new LocalFileDetector());
} catch (WebDriverException e) {
String message = e.getMessage();
if (message != null &&
!message.contains(NO_FILE_DETECTOR_NEEDED)) {
throw e;
}
}
}
}
示例6: cleanValueToSend
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的package包/类
/**
* When send keys is being executed in a input file=type {@link LocalFileDetector} must be configured for remote drivers. Additionally,
* the file path is expanded to be absolute
*
* @param driver used to run commands
* @param element receiving keys
* @param value to be set to input file type
* @return value expanded to absolute path if for input file type.
*/
private String cleanValueToSend(WebDriver driver, WebElement element, String value) {
if (!StringUtils.equals(element.getAttribute(SeleniumFixture.INPUT_TYPE_ATTRIBUTE), SeleniumFixture.INPUT_TYPE_FILE_VALUE)) {
return this.fitnesseMarkup.clean(value);
}
// set file detector for remote web elements. Local FirefoxDriver uses RemoteWebElement and
if (element instanceof RemoteWebElement && !ClassUtils.isAssignable(driver.getClass(), FirefoxDriver.class)) {
((RemoteWebElement) element).setFileDetector(new LocalFileDetector());
}
return this.fitnesseMarkup.cleanFile(value).getAbsolutePath();
}
示例7: getSeleniumGridRemoteDriver
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的package包/类
private static WebDriver getSeleniumGridRemoteDriver() throws MalformedURLException {
final DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setBrowserName(System.getProperty("selenium.grid.browser", "firefox"));
desiredCapabilities.setVersion(System.getProperty("selenium.grid.version", ""));
desiredCapabilities.setPlatform(Platform.ANY);
final URL url = new URL("http", System.getProperty("selenium.grid"), Integer.valueOf(System.getProperty(
"selenium.grid.port", "4444")), "/wd/hub");
final RemoteWebDriver remoteWebDriver = new RemoteWebDriver(url,
desiredCapabilities);
remoteWebDriver.setFileDetector(new LocalFileDetector());
return new Augmenter().augment(remoteWebDriver);
}
示例8: getWebDriver
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的package包/类
@Override
public WebDriver getWebDriver(SupportedBrowser browserType) {
RemoteWebDriver remoteDriver = new RemoteWebDriver(gridHubURL,
desiredCapabilities, browserType.toCapabilities());
remoteDriver.setFileDetector(new LocalFileDetector());
return remoteDriver;
}
示例9: createDriver
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的package包/类
@Override
public T createDriver() {
T remoteWebDriver = constr.apply(url, capabilities);
FileDetector fd = remoteWebDriver.getFileDetector();
if (fd == null || fd instanceof UselessFileDetector) {
remoteWebDriver.setFileDetector(new LocalFileDetector());
}
Environment.getInstance().setSymbol(REMOTE_URL_KEY, url.toString());
return remoteWebDriver;
}
示例10: webDriver
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的package包/类
@Bean
public WebDriver webDriver() {
PhantomJsDriverManager.getInstance().version("2.1.1").arch64().setup();
final PhantomJSDriver phantomJSDriver = new PhantomJSDriver();
phantomJSDriver.setFileDetector(new LocalFileDetector());
return phantomJSDriver;
}
示例11: create
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的package包/类
public WebDriver create(WebDriverProperties webDriverProperties) throws IOException {
DesiredCapabilities desiredCapabilities = new DesiredCapabilities(webDriverProperties.getDesiredCapabilities());
desiredCapabilities.merge(browserSpecificCapabilities(webDriverProperties));
WebDriver webDriver = null;
if (webDriverProperties.getUrl() != null) {
RemoteWebDriver remoteDriver = new RemoteWebDriver(webDriverProperties.getUrl(), desiredCapabilities);
remoteDriver.setFileDetector(new LocalFileDetector());
webDriver = remoteDriver;
} else {
String browserName = desiredCapabilities == null ? null : desiredCapabilities.getBrowserName();
if (Strings.isNullOrEmpty(browserName)) browserName = BrowserType.CHROME;
webDriver = WebDriverType.typeFor(browserName).create(this, desiredCapabilities);
}
WindowProperties window = webDriverProperties.getWindow();
if (window != null) {
DimensionProperties size = window.getSize();
PointProperties position = window.getPosition();
if (size != null) webDriver.manage().window().setSize(new Dimension(size.getWidth(), size.getHeight()));
if (position != null) webDriver.manage().window().setPosition(new Point(position.getX(), position.getY()));
if (window.isMaximized()) {
webDriver.manage().window().maximize();
}
}
webDriver = webDriver instanceof TakesScreenshot ? webDriver : new Augmenter().augment(webDriver);
for (WebDriverTransformer transformer : driverServices.getWebDriverTranformers()) webDriver = transformer.transform(webDriver);
return webDriverProperties.isStateful() ? new StatefulWebDriver(webDriver) : webDriver;
}
示例12: createDriver
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的package包/类
@Override
public WebDriver createDriver(URL remoteUrl) throws IOException {
if (isRemoteDriver()) {
RemoteWebDriver driver = new RemoteWebDriver(remoteUrl, DesiredCapabilities.htmlUnit());
driver.setFileDetector(new LocalFileDetector());
return driver;
} else {
return createDriver();
}
}
示例13: createDriver
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的package包/类
@Override
public WebDriver createDriver(URL remoteUrl) throws IOException {
FirefoxOptions options = getFirefoxOptions();
if (isRemoteDriver()) {
RemoteWebDriver driver = new RemoteWebDriver(remoteUrl, options);
driver.setFileDetector(new LocalFileDetector());
return driver;
} else {
return new FirefoxDriver(options);
}
}
示例14: createDriver
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的package包/类
@Override
public WebDriver createDriver(URL remoteUrl) throws IOException {
ChromeOptions options = getChromeOptions();
if (isRemoteDriver()) {
RemoteWebDriver driver = new RemoteWebDriver(remoteUrl, options);
driver.setFileDetector(new LocalFileDetector());
return driver;
} else {
return new ChromeDriver(options);
}
}
示例15: createDriver
import org.openqa.selenium.remote.LocalFileDetector; //导入依赖的package包/类
@Override
public WebDriver createDriver(URL remoteUrl) throws IOException {
InternetExplorerOptions capabilities = getOptions();
if (isRemoteDriver()) {
RemoteWebDriver driver = new RemoteWebDriver(remoteUrl, capabilities);
driver.setFileDetector(new LocalFileDetector());
return driver;
} else {
return new InternetExplorerDriver(capabilities);
}
}