本文整理汇总了Java中org.openqa.selenium.remote.CommandInfo类的典型用法代码示例。如果您正苦于以下问题:Java CommandInfo类的具体用法?Java CommandInfo怎么用?Java CommandInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandInfo类属于org.openqa.selenium.remote包,在下文中一共展示了CommandInfo类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProxyExecutor
import org.openqa.selenium.remote.CommandInfo; //导入依赖的package包/类
public static HttpCommandExecutor getProxyExecutor(URL url, Properties prop) {
prop = decrypt(prop);
String proxyHost = prop.getProperty("proxyHost");
int proxyPort = Integer.valueOf(prop.getProperty("proxyPort"));
String proxyUserDomain = prop.getProperty("proxyUserDomain");
String proxyUser = prop.getProperty("proxyUser");
String proxyPassword = prop.getProperty("proxyPassword");
HttpClientBuilder builder = HttpClientBuilder.create();
HttpHost proxy = new HttpHost(proxyHost, proxyPort);
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(proxyHost, proxyPort),
new NTCredentials(proxyUser, proxyPassword, getWorkstation(), proxyUserDomain));
if (url.getUserInfo() != null && !url.getUserInfo().isEmpty()) {
credsProvider.setCredentials(new AuthScope(url.getHost(), (url.getPort() > 0 ? url.getPort() : url.getDefaultPort())),
new UsernamePasswordCredentials(proxyUser, proxyPassword));
}
builder.setProxy(proxy);
builder.setDefaultCredentialsProvider(credsProvider);
HttpClient.Factory factory = new SimpleHttpClientFactory(builder);
return new HttpCommandExecutor(new HashMap<String, CommandInfo>(), url, factory);
}
示例2: createWebDriver
import org.openqa.selenium.remote.CommandInfo; //导入依赖的package包/类
public WebDriverEx createWebDriver(DriverService driverService,
DesiredCapabilities desiredCapabilities,
SiteConfig siteConfig,
DriverConfig driverConfig) throws IOException {
driverService.start();
//自定义HttpClientFactory用于设置命令超时时间
ApacheHttpClient.Factory httpClientFactory = createHttpClientFactory(siteConfig, driverConfig);
HttpCommandExecutor httpCommandExecutor = new HttpCommandExecutor(
ImmutableMap.<String, CommandInfo>of(), driverService.getUrl(), httpClientFactory);
WebDriverEx webDriver = new WebDriverEx(httpCommandExecutor, desiredCapabilities);
webDriver.setDriverService(driverService);
webDriver.setCreatedTime(new Date());
webDriver.manage().timeouts().implicitlyWait(driverConfig.getImplicitlyWait(), TimeUnit.MILLISECONDS);
webDriver.manage().timeouts().pageLoadTimeout(driverConfig.getPageLoadTimeout(), TimeUnit.MILLISECONDS);
webDriver.manage().timeouts().setScriptTimeout(driverConfig.getScriptTimeout(), TimeUnit.MILLISECONDS);
return webDriver;
}
示例3: AppiumCommandExecutor
import org.openqa.selenium.remote.CommandInfo; //导入依赖的package包/类
public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
URL addressOfRemoteServer, HttpClient.Factory httpClientFactory) {
super(additionalCommands, addressOfRemoteServer, httpClientFactory);
service = null;
}
示例4: createCommandRepository
import org.openqa.selenium.remote.CommandInfo; //导入依赖的package包/类
private static Map<String, CommandInfo> createCommandRepository() {
HashMap<String, CommandInfo> result = new HashMap<String, CommandInfo>();
result.put(RESET, postC("/session/:sessionId/appium/app/reset"));
result.put(GET_STRINGS, postC("/session/:sessionId/appium/app/strings"));
result.put(SET_VALUE, postC("/session/:sessionId/appium/element/:id/value"));
result.put(PULL_FILE, postC("/session/:sessionId/appium/device/pull_file"));
result.put(PULL_FOLDER, postC("/session/:sessionId/appium/device/pull_folder"));
result.put(HIDE_KEYBOARD, postC("/session/:sessionId/appium/device/hide_keyboard"));
result.put(RUN_APP_IN_BACKGROUND, postC("/session/:sessionId/appium/app/background"));
result.put(PERFORM_TOUCH_ACTION, postC("/session/:sessionId/touch/perform"));
result.put(PERFORM_MULTI_TOUCH, postC("/session/:sessionId/touch/multi/perform"));
result.put(IS_APP_INSTALLED, postC("/session/:sessionId/appium/device/app_installed"));
result.put(INSTALL_APP, postC("/session/:sessionId/appium/device/install_app"));
result.put(REMOVE_APP, postC("/session/:sessionId/appium/device/remove_app"));
result.put(LAUNCH_APP, postC("/session/:sessionId/appium/app/launch"));
result.put(CLOSE_APP, postC("/session/:sessionId/appium/app/close"));
result.put(LOCK, postC("/session/:sessionId/appium/device/lock"));
result.put(COMPLEX_FIND, postC("/session/:sessionId/appium/app/complex_find"));
result.put(GET_SETTINGS, getC("/session/:sessionId/appium/settings"));
result.put(SET_SETTINGS, postC("/session/:sessionId/appium/settings"));
result.put(GET_DEVICE_TIME, getC("/session/:sessionId/appium/device/system_time"));
result.put(GET_SESSION,getC("/session/:sessionId/"));
//iOS
result.put(SHAKE, postC("/session/:sessionId/appium/device/shake"));
//Android
result.put(CURRENT_ACTIVITY,
getC("/session/:sessionId/appium/device/current_activity"));
result.put(END_TEST_COVERAGE,
postC("/session/:sessionId/appium/app/end_test_coverage"));
result.put(GET_NETWORK_CONNECTION, getC("/session/:sessionId/network_connection"));
result.put(IS_LOCKED, postC("/session/:sessionId/appium/device/is_locked"));
result.put(LONG_PRESS_KEY_CODE,
postC("/session/:sessionId/appium/device/long_press_keycode"));
result.put(OPEN_NOTIFICATIONS,
postC("/session/:sessionId/appium/device/open_notifications"));
result.put(PRESS_KEY_CODE,
postC("/session/:sessionId/appium/device/press_keycode"));
result.put(PUSH_FILE, postC("/session/:sessionId/appium/device/push_file"));
result.put(SET_NETWORK_CONNECTION,
postC("/session/:sessionId/network_connection"));
result.put(START_ACTIVITY,
postC("/session/:sessionId/appium/device/start_activity"));
result.put(TOGGLE_LOCATION_SERVICES,
postC("/session/:sessionId/appium/device/toggle_location_services"));
result.put(UNLOCK, postC("/session/:sessionId/appium/device/unlock"));
result.put(REPLACE_VALUE, postC("/session/:sessionId/appium/element/:id/replace_value"));
return result;
}
示例5: createGridExecutor
import org.openqa.selenium.remote.CommandInfo; //导入依赖的package包/类
/**
* Returns an {@link URL} to a Selenium grid (e.g. SauceLabs) that contains basic authentication for access
*
* @return {@link URL} to Selenium grid augmented with credentials
* @throws MalformedURLException
*/
public static HttpCommandExecutor createGridExecutor(ProxyConfigurationDto proxyConfig, URL gridUrl, String gridUsername,
String gridPassword) throws MalformedURLException
{
// create a configuration for accessing target site via proxy (if a proxy is defined)
// the proxy and the destination site will have different or no credentials for accessing them
// so we need to create different authentication scopes and link them with the credentials
BasicCredentialsProvider basicCredentialsProvider = new BasicCredentialsProvider();
// create credentials for proxy access
if (proxyConfig != null //
&& !StringUtils.isEmpty(proxyConfig.getUsername()) //
&& !StringUtils.isEmpty(proxyConfig.getPassword()))
{
AuthScope proxyAuth = new AuthScope(proxyConfig.getHost(), Integer.valueOf(proxyConfig.getPort()));
Credentials proxyCredentials = new UsernamePasswordCredentials(proxyConfig.getUsername(), proxyConfig.getPassword());
basicCredentialsProvider.setCredentials(proxyAuth, proxyCredentials);
}
// create credentials for target website
AuthScope gridAuth = new AuthScope(gridUrl.getHost(), gridUrl.getPort());
if (!StringUtils.isEmpty(gridUsername))
{
Credentials gridCredentials = new UsernamePasswordCredentials(gridUsername, gridPassword);
basicCredentialsProvider.setCredentials(gridAuth, gridCredentials);
}
// now create a http client, set the custom proxy and inject the credentials
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
clientBuilder.setDefaultCredentialsProvider(basicCredentialsProvider);
if (proxyConfig != null)
clientBuilder.setProxy(new HttpHost(proxyConfig.getHost(), Integer.valueOf(proxyConfig.getPort())));
CloseableHttpClient httpClient = clientBuilder.build();
Map<String, CommandInfo> additionalCommands = new HashMap<String, CommandInfo>(); // just a dummy
// this command executor will do the credential magic for us. both proxy and target site credentials
return new HttpCommandExecutor(additionalCommands, gridUrl, new ProxyHttpClient(httpClient));
}
示例6: seleniumSetup
import org.openqa.selenium.remote.CommandInfo; //导入依赖的package包/类
/**
* Connect to selenium.
*
* @throws MalformedURLException
*/
@Before(order = ORDER_10, value = {"@mobile,@web"})
public void seleniumSetup() throws MalformedURLException {
String grid = System.getProperty("SELENIUM_GRID");
if (grid == null) {
fail("Selenium grid not available");
}
String b = ThreadProperty.get("browser");
if ("".equals(b)) {
fail("Non available browsers");
}
String browser = b.split("_")[0];
String version = b.split("_")[1];
commonspec.setBrowserName(browser);
commonspec.getLogger().debug("Setting up selenium for {}", browser);
DesiredCapabilities capabilities = null;
switch (browser.toLowerCase()) {
case "chrome":
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--ignore-certificate-errors");
capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
break;
case "firefox":
capabilities = DesiredCapabilities.firefox();
break;
case "phantomjs":
capabilities = DesiredCapabilities.phantomjs();
break;
case "iphone":
case "safari":
capabilities = DesiredCapabilities.iphone();
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "8.1");
capabilities.setCapability("deviceName", "iPhone Simulator");
break;
case "android":
capabilities = DesiredCapabilities.android();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "6.0");
capabilities.setCapability("deviceName", "Android Emulator");
capabilities.setCapability("app", "Browser");
break;
default:
commonspec.getLogger().error("Unknown browser: " + browser);
throw new SeleniumException("Unknown browser: " + browser);
}
capabilities.setVersion(version);
grid = "http://" + grid + "/wd/hub";
HttpClient.Factory factory = new ApacheHttpClient.Factory(new HttpClientFactory(60000, 60000));
HttpCommandExecutor executor = new HttpCommandExecutor(new HashMap<String, CommandInfo>(), new URL(grid), factory);
commonspec.setDriver(new RemoteWebDriver(executor, capabilities));
commonspec.getDriver().manage().timeouts().pageLoadTimeout(PAGE_LOAD_TIMEOUT, TimeUnit.SECONDS);
commonspec.getDriver().manage().timeouts().implicitlyWait(IMPLICITLY_WAIT, TimeUnit.SECONDS);
commonspec.getDriver().manage().timeouts().setScriptTimeout(SCRIPT_TIMEOUT, TimeUnit.SECONDS);
commonspec.getDriver().manage().deleteAllCookies();
if (capabilities.getCapability("deviceName") == null) {
commonspec.getDriver().manage().window().setSize(new Dimension(1440, 900));
}
commonspec.getDriver().manage().window().maximize();
}
示例7: newVendorCommand
import org.openqa.selenium.remote.CommandInfo; //导入依赖的package包/类
private static CommandInfo newVendorCommand(String path, HttpMethod method) {
return new CommandInfo(VENDOR_PREFIX + path, method);
}
示例8: getC
import org.openqa.selenium.remote.CommandInfo; //导入依赖的package包/类
/**
* This methods forms GET commands.
*
* @param url is the command URL
* @return an instance of {@link org.openqa.selenium.remote.CommandInfo}
*/
public static CommandInfo getC(String url) {
return new CommandInfo(url, HttpMethod.GET);
}
示例9: postC
import org.openqa.selenium.remote.CommandInfo; //导入依赖的package包/类
/**
* This methods forms POST commands.
*
* @param url is the command URL
* @return an instance of {@link org.openqa.selenium.remote.CommandInfo}
*/
public static CommandInfo postC(String url) {
return new CommandInfo(url, HttpMethod.POST);
}
示例10: deleteC
import org.openqa.selenium.remote.CommandInfo; //导入依赖的package包/类
/**
* This methods forms DELETE commands.
*
* @param url is the command URL
* @return an instance of {@link org.openqa.selenium.remote.CommandInfo}
*/
public static CommandInfo deleteC(String url) {
return new CommandInfo(url, HttpMethod.DELETE);
}