Skip to content

Commit

Permalink
Added Protocol-Capability (#382)
Browse files Browse the repository at this point in the history
- Updated DriverFactoryHelper to support "HTTPS" via configurable parameter "SELENIUM_PROTOCOL".
- Added Tests to complement previous commit concerning protocol capability.
- Bump chromedriver-version to 2.42 to work with the latest stable chrome
  • Loading branch information
marvindoering authored and mach6 committed Oct 17, 2018
1 parent 248163c commit 614302b
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,13 @@ public enum ConfigProperty {
* Automatically take screen shots.<br>
*/
AUTO_SCREEN_SHOT("autoScreenShot", "true", true),

/**
* Protocol might be http or https. Used when
* {@link ConfigProperty#SELENIUM_RUN_LOCALLY} is <b>false</b>.<br>
* Default is set to <b>"http"</b>
*/
SELENIUM_PROTOCOL("protocol", "http", true),

/**
* Selenium host might be localhost or another location where a Selenium server is running. Used when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ static URL getURL() {

URL url = null;
String hostToRun = Config.getConfigProperty(ConfigProperty.SELENIUM_HOST);
String protocol = Config.getConfigProperty(ConfigProperty.SELENIUM_PROTOCOL);

boolean runLocally = Boolean.parseBoolean(Config.getConfigProperty(ConfigProperty.SELENIUM_RUN_LOCALLY));
String port = Config.getConfigProperty(ConfigProperty.SELENIUM_PORT);
Expand All @@ -165,7 +166,7 @@ static URL getURL() {
+ "via the TestNG suite file parameter : <parameter name=\"seleniumhost\" value=\"\" />";
throw new IllegalStateException(errMsg);
}
url = new URL("http://" + hostToRun + ":" + port + "/wd/hub");
url = new URL(protocol + "://" + hostToRun + ":" + port + "/wd/hub");
} catch (MalformedURLException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*-------------------------------------------------------------------------------------------------------------------*\
| Copyright (C) 2018 PayPal |
| |
| 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. |
\*-------------------------------------------------------------------------------------------------------------------*/

package com.paypal.selion.configuration;

import java.util.HashMap;
import java.util.Map;

import org.testng.Assert;
import org.testng.ITestContext;
import org.testng.annotations.Test;

import com.paypal.selion.configuration.Config.ConfigProperty;

// Test requires execution with SeLionProtocolConfig-Suite.xml
public class ProtocolConfigTest {

@Test(groups = { "protocol" }, priority = 1)
public void testGetProtocalProperty() {
Assert.assertNotNull(Config.getConfigProperty(ConfigProperty.SELENIUM_PROTOCOL), "Get config property should not be null");
}

@Test(groups = { "protocol" }, priority = 2)
public void testInitProtocalConfig(ITestContext context) {
Config.initConfig(context);
Assert.assertNotNull(Config.getConfigProperty(ConfigProperty.SELENIUM_PROTOCOL), "Config should not be null");
}

@Test(groups = { "protocol" }, priority = 3)
public void testInitProtocalConfigNegative() {
Assert.assertFalse(Config.getConfigProperty(ConfigProperty.SELENIUM_PROTOCOL).contentEquals("http"),
"Negative-TC: PROTOCOL should match the suite-file. (https) is set in suite file -> not (http)");

}

@Test(groups = { "protocol" }, priority = 4)
public void testInitProtocalConfigChangeOption() {
Assert.assertEquals(Config.getConfigProperty(ConfigProperty.SELENIUM_PROTOCOL), "https",
"PROTOCOL should be (https)");
Map<ConfigProperty, String> initValues = new HashMap<ConfigProperty, String>();
initValues.put(ConfigProperty.SELENIUM_PROTOCOL, "http");
Config.initConfig(initValues);
Assert.assertEquals(Config.getConfigProperty(ConfigProperty.SELENIUM_PROTOCOL), "http",
"PROTOCOL should be (http)");
}


}
23 changes: 23 additions & 0 deletions client/src/test/resources/suites/SeLionProtocolConfig-Suite.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="100" verbose="1" name="SeLion Protocol Config Test Suite" skipfailedinvocationcounts="false" junit="false"
parallel="false" data-provider-thread-count="50" annotations="JDK">

<parameter name="protocol" value="https" />

<listeners>
<listener class-name="com.paypal.selion.reports.runtime.DebugListener" />
</listeners>


<test verbose="2" name="Test1" annotations="JDK">
<groups>
<run>
<include name="protocol" />
</run>
</groups>
<classes>
<class name="com.paypal.selion.configuration.ProtocolConfigTest" />
</classes>
</test>
</suite>

12 changes: 6 additions & 6 deletions server/src/main/resources/config/download.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
"name": "chromedriver",
"roles": [ "node", "standalone" ],
"windows": {
"url": "https://chromedriver.storage.googleapis.com/2.33/chromedriver_win32.zip",
"checksum": "718df64a6e2b2efde50b26ac22fde229"
"url": "https://chromedriver.storage.googleapis.com/2.42/chromedriver_win32.zip",
"checksum": "28d91b31311146250e7ef1afbcd6d026"
},
"linux": {
"url": "https://chromedriver.storage.googleapis.com/2.33/chromedriver_linux64.zip",
"checksum": "6dc329fb8ecdff6a9f74eea053434662"
"url": "https://chromedriver.storage.googleapis.com/2.42/chromedriver_linux64.zip",
"checksum": "acfcc29fb03df9e913ef4c360a121ad1"
},
"mac": {
"url": "https://chromedriver.storage.googleapis.com/2.33/chromedriver_mac64.zip",
"checksum": "3d520b8ede8e9deb8c9a2efe2aec5f35"
"url": "https://chromedriver.storage.googleapis.com/2.42/chromedriver_mac64.zip",
"checksum": "3fc0e4a97cbf2c8c2a9b824d95e25351"
}
},
{
Expand Down

0 comments on commit 614302b

Please sign in to comment.