Skip to content

Commit

Permalink
intermediate revision - preparing for the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
sergueik committed Jul 31, 2016
1 parent 345111b commit 69cc214
Show file tree
Hide file tree
Showing 19 changed files with 2,622 additions and 3,421 deletions.
23 changes: 18 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,32 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.jprotractor</groupId>
<artifactId>jprotractor</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>jprotractor</name>
<url/>
<developers>
<developer>
<name>Carlos Alexandro Becker</name>
<email>[email protected]</email>
<organization></organization>
<organizationUrl>https://github.com/caarlos0</organizationUrl>
</developer>
<developer>
<name>Serguei Kouzmine</name>
<email>[email protected]</email>
<organization></organization>
<organizationUrl>https://github.com/sergueik</organizationUrl>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<java.version>1.7</java.version>
<selenium.version>2.44.0</selenium.version>
<selenium-firefox-driver.version>2.43.1</selenium-firefox-driver.version>
<junit.version>4.11</junit.version>
<selenium.version>2.44.0</selenium.version>
<selenium.version>2.47.0</selenium.version>
<selenium-firefox-driver.version>2.47.0</selenium-firefox-driver.version>
<junit.version>4.12</junit.version>
<phantomjsdriver.version>1.2.1</phantomjsdriver.version>
<maven-compiler-plugin.version>2.0.2</maven-compiler-plugin.version>
</properties>
Expand Down
36 changes: 25 additions & 11 deletions src/test/java/com/jprotractor/integration/CommonFunctions.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.IOException;

import java.util.Map;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -50,7 +53,7 @@ public class CommonFunctions {
static boolean isDestopTesting = true;
static boolean isCIBuild = false;
private static long highlightInterval = 100;
private static Map <String,String>env = System.getenv();
private static Map<String, String> env = System.getenv();

public static WebDriver getSeleniumDriver() throws IOException {
checkEnvironment();
Expand All @@ -60,25 +63,25 @@ public static WebDriver getSeleniumDriver() throws IOException {
// For Vagrant box browser testing have localhost port 4444 forwarded to
// the hub 4444

DesiredCapabilities capabilities = new DesiredCapabilities("firefox", "",
DesiredCapabilities capabilities = new DesiredCapabilities("chrome", "",
Platform.ANY);
seleniumDriver = new FirefoxDriver(capabilities);
// seleniumDriver = new FirefoxDriver(capabilities);
// FirefoxProfile profile = new ProfilesIni().getProfile("default");
// profile.setEnableNativeEvents(false);
// capabilities.setCapability("firefox_profile", profile);

// seleniumDriver = new RemoteWebDriver(new
// URL("http://127.0.0.1:4444/wd/hub"), capabilities);
seleniumDriver = new RemoteWebDriver(new URL(
"http://127.0.0.1:4444/wd/hub"), capabilities);
return seleniumDriver;
} else {
DesiredCapabilities capabilities = new DesiredCapabilities("phantomjs",
"", Platform.ANY);
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS,
new String[] { "--web-security=false", "--ssl-protocol=any",
"--ignore-ssl-errors=true", "--local-to-remote-url-access=true",
"--ignore-ssl-errors=true", "--local-to-remote-url-access=true",
// prevent local file test XMLHttpRequest Exception 101
"--webdriver-loglevel=INFO"
// set to DEBUG for a really verbose console output
"--webdriver-loglevel=INFO"
// set to DEBUG for a really verbose console output
});

seleniumDriver = new PhantomJSDriver(capabilities);
Expand Down Expand Up @@ -107,6 +110,19 @@ protected static String getPageContent(String pagename) {
}
}

protected static String getScriptContent(String scriptName) throws Exception {
try {
final InputStream stream = CommonFunctions.class.getClassLoader()
.getResourceAsStream(scriptName);
final byte[] bytes = new byte[stream.available()];
stream.read(bytes);
// System.err.println(new String(bytes, "UTF-8"));
return new String(bytes, "UTF-8");
} catch (IOException e) {
throw new Exception(scriptName);
}
}

public static void setHighlightTimeout(long value) {
highlightInterval = value;
}
Expand All @@ -127,9 +143,7 @@ public static Object executeScript(String script, Object... args) {
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) seleniumDriver;
return javascriptExecutor.executeScript(script, args);
} else {
throw new RuntimeException(
"Script execution is only available for WebDrivers that implement "
+ "the JavascriptExecutor interface.");
throw new RuntimeException("Script execution failed.");
}
}
}
Loading

0 comments on commit 69cc214

Please sign in to comment.