Skip to content
This repository was archived by the owner on Nov 23, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
0f21b55
Browser-specific driver creation moved to dedicated creators; introdu…
mkrzyzanowski Jan 2, 2019
e727959
WebDriverProvider is using new creators now
mkrzyzanowski Jan 2, 2019
845f91c
Merge branch 'master' into webdriver-init-rework
mkrzyzanowski Jan 3, 2019
3be3776
Added additional logging to drivers initialization
mkrzyzanowski Jan 3, 2019
2325851
Removing few dependencies from WebDriverProvider; now ClosingAwareWeb…
mkrzyzanowski Jan 3, 2019
4082d16
Simplified WebDriverProvider even further
mkrzyzanowski Jan 3, 2019
63d5900
Splitting responsibilites, extracted CapabilitiesModifiers and applyi…
mkrzyzanowski Jan 4, 2019
684dcc5
AppiumDriverCreator split into Ios- and Android-specific creators
mkrzyzanowski Jan 4, 2019
cafe34a
ChromeOptions: enabled setting headless and accepting insecure certs
mkrzyzanowski Jan 4, 2019
32aa494
Merge branch 'master' into webdriver-init-rework
mkrzyzanowski Jul 29, 2019
91cc8f9
WebDriver init rework - WIP
mkrzyzanowski Jul 31, 2019
9c0ecbe
Merge branch 'master' into webdriver-init-rework
mkrzyzanowski Jul 31, 2019
c5fa1a5
Fixed version in Appium module; excluded creators test from main test…
mkrzyzanowski Jul 31, 2019
87a7385
Merge branch 'master' into webdriver-init-rework
mkrzyzanowski Aug 8, 2019
0ed63ff
WebDriver initialisation reworked
mkrzyzanowski Aug 13, 2019
fffc170
Add missing license header; added bb-appium module name
mkrzyzanowski Aug 13, 2019
0baf487
Fixed unit test [skip-ci]
mkrzyzanowski Aug 13, 2019
b62060c
Self-CR fixes
mkrzyzanowski Aug 13, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions bb-appium/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Bobcat
%%
Copyright (C) 2019 Cognifide Ltd.
%%
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#L%
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>bobcat</artifactId>
<groupId>com.cognifide.qa.bb</groupId>
<version>2.1.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>bb-appium</artifactId>
<name>Bobcat Appium</name>

<dependencies>
<dependency>
<groupId>com.cognifide.qa.bb</groupId>
<artifactId>bb-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*-
* #%L
* Bobcat
* %%
* Copyright (C) 2019 Cognifide Ltd.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.cognifide.qa.bb.appium.modules;

import com.google.inject.AbstractModule;

/**
* Main Guice module of the {@code bb-appium} module. Add it to your project's module or in your runmode file.
*/
public class AppiumModule extends AbstractModule {
@Override
protected void configure() {
install(new WebdriverCreatorsModule());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*-
* #%L
* Bobcat
* %%
* Copyright (C) 2019 Cognifide Ltd.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.cognifide.qa.bb.appium.modules;

import com.cognifide.qa.bb.appium.webdriver.creators.AndroidDriverCreator;
import com.cognifide.qa.bb.appium.webdriver.creators.IosDriverCreator;
import com.cognifide.qa.bb.provider.selenium.webdriver.creators.WebDriverCreator;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;

/**
* Registers WebDriverCreators from this module
*/
public class WebdriverCreatorsModule extends AbstractModule {
@Override
protected void configure() {
Multibinder<WebDriverCreator> creators =
Multibinder.newSetBinder(binder(), WebDriverCreator.class);

creators.addBinding().to(AndroidDriverCreator.class);
creators.addBinding().to(IosDriverCreator.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*-
* #%L
* Bobcat
* %%
* Copyright (C) 2019 Cognifide Ltd.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.cognifide.qa.bb.appium.webdriver.creators;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;

import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cognifide.qa.bb.constants.ConfigKeys;
import com.cognifide.qa.bb.provider.selenium.webdriver.creators.WebDriverCreator;
import com.google.inject.Inject;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobilePlatform;

/**
* Creates instances of {@link AndroidDriver}
*/
public class AndroidDriverCreator implements WebDriverCreator {

private static final Logger LOG = LoggerFactory.getLogger(AndroidDriverCreator.class);
private static final String ID = "android";

@Inject
private Properties properties;

@Override
public WebDriver create(Capabilities capabilities) {
LOG.info("Starting the initialization of '{}' WebDriver instance", ID);
LOG.debug("Initializing WebDriver with following capabilities: {}", capabilities);
return createMobileDriver(capabilities, properties);
}

@Override
public String getId() {
return ID;
}

private WebDriver createMobileDriver(Capabilities capabilities, Properties properties) {
final URL url;
try {
url = new URL(properties.getProperty(ConfigKeys.WEBDRIVER_APPIUM_URL));
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Your Appium URL seems to be malformed", e);
}

final String platform = properties.getProperty(ConfigKeys.WEBDRIVER_CAP_PLATFORM_NAME);
if (MobilePlatform.ANDROID.equals(platform)) {
return new AndroidDriver(url, capabilities);
} else {
throw new IllegalArgumentException(String.format(
"Requested Android driver but incorrect platform name was provided. %s should be set to: %s",
ConfigKeys.WEBDRIVER_CAP_PLATFORM_NAME, MobilePlatform.ANDROID));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*-
* #%L
* Bobcat
* %%
* Copyright (C) 2019 Cognifide Ltd.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.cognifide.qa.bb.appium.webdriver.creators;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;

import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cognifide.qa.bb.constants.ConfigKeys;
import com.cognifide.qa.bb.provider.selenium.webdriver.creators.WebDriverCreator;
import com.google.inject.Inject;

import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.remote.MobilePlatform;

/**
* Creates instances of {@link IOSDriver}
*/
public class IosDriverCreator implements WebDriverCreator {

private static final Logger LOG = LoggerFactory.getLogger(IosDriverCreator.class);
private static final String ID = "ios";

@Inject
private Properties properties;

@Override
public WebDriver create(Capabilities capabilities) {
LOG.info("Starting the initialization of '{}' WebDriver instance", ID);
LOG.debug("Initializing WebDriver with following capabilities: {}", capabilities);
return createMobileDriver(capabilities, properties);
}

@Override
public String getId() {
return ID;
}

private WebDriver createMobileDriver(Capabilities capabilities, Properties properties) {
final URL url;
try {
url = new URL(properties.getProperty(ConfigKeys.WEBDRIVER_APPIUM_URL));
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Your Appium URL seems to be malformed", e);
}

final String platform = properties.getProperty(ConfigKeys.WEBDRIVER_CAP_PLATFORM_NAME);
if (platform == null) {
throw new IllegalStateException(String.format("%s is missing. Set it either to %s or %s",
ConfigKeys.WEBDRIVER_CAP_PLATFORM_NAME, MobilePlatform.ANDROID, MobilePlatform.IOS));
}
if (MobilePlatform.IOS.equals(platform)) {
return new IOSDriver(url, capabilities);
} else {
throw new IllegalArgumentException(String.format(
"Requested iOS driver but incorrect platform name was provided. %s should be set to: %s",
ConfigKeys.WEBDRIVER_CAP_PLATFORM_NAME, MobilePlatform.IOS));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*-
* #%L
* Bobcat
* %%
* Copyright (C) 2019 Cognifide Ltd.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.cognifide.qa.bb.appium;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

import org.junit.jupiter.api.Test;

import com.cognifide.qa.bb.appium.modules.AppiumModule;
import com.google.inject.Guice;
import com.google.inject.Stage;

class AppiumModuleTest {

@Test
void allBindingsAreConfiguredCorrectly() {
assertDoesNotThrow(() -> Guice.createInjector(Stage.TOOL, new AppiumModule()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public final class ConfigKeys {

public static final String WEBDRIVER_CAP_PLATFORM_NAME = "webdriver.cap.platformName";

public static final String WEBDRIVER_FIREFOX_BIN = "webdriver.firefox.bin";

public static final String WEBDRIVER_MAXIMIZE = "webdriver.maximize";

public static final String WEBDRIVER_MOBILE = "webdriver.mobile";
Expand All @@ -49,8 +47,6 @@ public final class ConfigKeys {

public static final String WEBDRIVER_TYPE = "webdriver.type";

public static final String WEBDRIVER_XVFB_ID = "webdriver.xvfb.id";

public static final String WEBDRIVER_URL = "webdriver.url";

public static final String CONFIG_STRATEGY = "bobcat.config";
Expand All @@ -66,6 +62,10 @@ public final class ConfigKeys {
public static final String TIMINGS_IMPLICIT_TIMEOUT = TIMINGS_PREFIX + "implicitTimeout";
public static final String TIMINGS_POLLING_INTERVAL = TIMINGS_PREFIX + "pollingInterval";

//Chrome options
public static final String CHROME_HEADLESS = "webdriver.chrome.headless";
public static final String CHROME_ACCEPT_INSECURE_CERTS = "webdriver.chrome.acceptInsecureCerts";

private ConfigKeys() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ protected void configure() {

install(new PropertyModule());

install(new SeleniumModule());

install(new PageObjectsModule());

install(new WebdriverModule());

install(new WebdriverCreatorsModule());

install(new BobcatWebElementModule());

install(new FrameModule());
Expand Down
Loading