Skip to content

Commit

Permalink
Adding microsoft edge browser support to the SeLion client
Browse files Browse the repository at this point in the history
  • Loading branch information
sundaramrajendran committed Nov 12, 2015
1 parent d394197 commit e70faaa
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-------------------------------------------------------------------------------------------------------------------*\
| Copyright (C) 2014 PayPal |
| Copyright (C) 2014-15 PayPal |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance |
| with the License. |
Expand Down Expand Up @@ -409,6 +409,12 @@ public static enum ConfigProperty {
*/
SELENIUM_IEDRIVER_PATH("ieDriverPath", "", true),

/**
* The path to the EdgeDriver executable on the local machine. This parameter is taken into consideration for
* local runs involving the Edge browser.
*/
SELENIUM_EDGEDRIVER_PATH("edgeDriverPath", "", true),

/**
* Use this parameter to set the user agent for firefox when working with Mobile version. This parameter should
* be set in conjunction with the parameter {@link ConfigProperty#BROWSER}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
public enum BrowserFlavors {
FIREFOX("*firefox"),
INTERNET_EXPLORER("*iexplore"),
MICROSOFT_EDGE("*microsoftedge"),
HTMLUNIT("*htmlunit"),
CHROME("*chrome"),
SAFARI("*safari"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*-------------------------------------------------------------------------------------------------------------------*\
| Copyright (C) 2015 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.internal.platform.grid.browsercapabilities;

import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

import com.paypal.selion.SeLionConstants;
import com.paypal.selion.configuration.Config;
import com.paypal.selion.configuration.Config.ConfigProperty;
import com.paypal.selion.platform.grid.browsercapabilities.DefaultCapabilitiesBuilder;

/**
* This class represents the capabilities that are specific to Edge browser.
*/
class EdgeCapabilitiesBuilder extends DefaultCapabilitiesBuilder {

@Override
public DesiredCapabilities getCapabilities(DesiredCapabilities capabilities) {
if (isLocalRun() && StringUtils.isNotBlank(getBinaryPath())) {
System.setProperty(SeLionConstants.WEBDRIVER_EDGE_DRIVER_PROPERTY, getBinaryPath());
}
capabilities.setBrowserName(DesiredCapabilities.edge().getBrowserName());
if (ProxyHelper.isProxyServerRequired()) {
capabilities.setCapability(CapabilityType.PROXY, ProxyHelper.createProxyObject());
}
return capabilities;
}

/*
* Returns the location of edgedriverserver or "" if it can not be determined.
*/
private String getBinaryPath() {
String location = System.getProperty(SeLionConstants.WEBDRIVER_EDGE_DRIVER_PROPERTY,
Config.getConfigProperty(ConfigProperty.SELENIUM_EDGEDRIVER_PATH));
return location;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public static RemoteWebDriver createInstance(BrowserFlavors browser) {
case INTERNET_EXPLORER:
capability = new IECapabilitiesBuilder().createCapabilities();
break;
case MICROSOFT_EDGE:
capability = new EdgeCapabilitiesBuilder().createCapabilities();
break;
case HTMLUNIT:
capability = new HtmlUnitCapabilitiesBuilder().createCapabilities();
break;
Expand Down
46 changes: 46 additions & 0 deletions client/src/test/java/com/paypal/selion/sample/EdgeBrowserTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*-------------------------------------------------------------------------------------------------------------------*\
| Copyright (C) 2015 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.sample;

import static org.testng.Assert.assertNotNull;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;

import com.paypal.selion.annotations.WebTest;
import com.paypal.selion.platform.grid.Grid;

/*
* DEVNOTE Tests in this class exist primarily for demonstration purposes and as a basic sanity checks.
*/
public class EdgeBrowserTest {

@Test
@WebTest
public void testGoogleOnEdge() {
RemoteWebDriver driver = Grid.driver();
assertNotNull(driver);
// And now use this to visit Google
driver.get("http://www.google.com");

// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));

// Enter something to search for
element.sendKeys("Cheese!");
}
}
18 changes: 18 additions & 0 deletions client/src/test/resources/suites/EdgeSauceCloudSuite.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite verbose="1" name="Edge Browser Test Suite" annotations="JDK">

<!-- SELENIUM CONFIGURATION -->
<parameter name="browser" value="*microsoftedge" />
<parameter name="platform" value="Windows 10" />
<parameter name="useSauceLabGrid" value="true" />
<parameter name="seleniumhost" value="ondemand.saucelabs.com" />
<parameter name="seleniumport" value="80"></parameter>

<test verbose="2" name="Edge-SauceCloud-Test" annotations="JDK">
<classes>
<class name="com.paypal.selion.sample.EdgeBrowserTest"></class>
</classes>
</test>

</suite>

4 changes: 4 additions & 0 deletions common/src/main/java/com/paypal/selion/SeLionConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ public class SeLionConstants {
*/
public static final String WEBDRIVER_PHANTOMJS_DRIVER_PROPERTY = "phantomjs.binary.path";

/**
* Selenium system property for defining the location of edge driver.
*/
public static final String WEBDRIVER_EDGE_DRIVER_PROPERTY = "webdriver.edge.driver";
}

0 comments on commit e70faaa

Please sign in to comment.