Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for headless chrome #325

Closed
wants to merge 1 commit into from
Closed

Conversation

paulpach
Copy link

This example shows how to run jasmine tests in headless chrome.

This example shows how to run jasmine tests in headless chrome.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 58.591% when pulling b16342f on paulpach:master into dc3ef56 on searls:master.

@yournans
Copy link

Example to run jasmine tests with chrome options helps me. But I am unable to set up "webdriver.chrome.driver" in my pom.xml so that jasmine plugin recognizes where chrome driver is. I tried various options like using "systemPropertyVariables", "argLine" and "jvmArguments" but none helps.

<configuration>
    <argLine>-Dwebdriver.chrome.driver=/path/chromedriver.exe
</configuration>
<configuration>
    <systemPropertyVariables>
        <webdriver.chrome.driver>/path/chromedriver.exe</webdriver.chrome.driver>
    </systemPropertyVariables>
</configuration>
<configuration>
    <jvmArguments>
        -Dwebdriver.chrome.driver=/path/chromedriver.exe
    </jvmArguments>
</configuration>

I tried the above settings in the following plug ins:

<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>

I always get the following error when I run "mvn":

[ERROR] Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html

As a workaround if I run "mvn" as below it works:
mvn -Dwebdriver.chrome.driver=/path/chromedriver.exe

How do I set it up in pom.xml? What I am doing wrong? Please help

@paulpach
Copy link
Author

Try adding a property to the pom like this:

<properties>
    <webdriver.chrome.driver>/path/chromedriver.exe</webdriver.chrome.driver>
</properties

Read the documentation.

Or better yet, add /path to your PATH environment variable, then you don't have to hardcode the path in your pom and it becomes more portable.

@yournans
Copy link

yournans commented Nov 27, 2017

Thanks @paulpach! But it does not help (setting in properties section of pom.xml). As of now I have added that property in mvn file(/{mvn-home-folder}/bin) as a workaround:

exec "$JAVACMD" \
  $MAVEN_OPTS \
  -classpath "${M2_HOME}"/boot/plexus-classworlds-*.jar \
  "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
  "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
"-Dwebdriver.chrome.driver=/path/chromedriver.exe" \
  ${CLASSWORLDS_LAUNCHER} "$@"

But I am amazed how others are managing to do it without setting up in Windows PATH environment variable or changing mvn file.

@paulpach
Copy link
Author

paulpach commented Nov 27, 2017 via email

@ghost
Copy link

ghost commented Feb 2, 2018

Just hit the same problem as @yournans mentioned. I can't find any way to specify the path to chromedriver other than using mvn -Dwebdriver.chrome.driver=/path/chromedriver.exe . Has anybody solved the problem? I'm also curious is that possible somehow to run download process of chromedriver and then use it in jasmine-maven-plugin the same way it is with phantomjs?

@klieber
Copy link
Collaborator

klieber commented Feb 19, 2018

The next release will use headless Chrome as the default driver. You can checkout an alpha version of it here: https://github.com/searls/jasmine-maven-plugin/releases/tag/jasmine-maven-plugin-3.0-alpha-01

@ghost
Copy link

ghost commented Feb 19, 2018

Thanks @klieber, I've already checked the alpha version, great job! While it works well on machines with Chrome already installed, it is not shipping the Chrome itself, without which the Chrome driver is useless. So If with "all-in-one" Phantomjs the build and test process was fully automated, now we need to handle manual Chrome installation. Are there any ideas about how to handle that using maven plugin?

@klieber
Copy link
Collaborator

klieber commented Feb 20, 2018

I don't think that is going to be possible anymore. PhantomJS is basically a dead project now and there really isn't any other way to install a simple single binary to use as the browser. Requiring a browser be installed is pretty standard these days anymore and what similar tools are doing so I don't have plans to dig into it anymore. Also, if you use Docker for your builds then there really isn't any problem because you can just install the browser with docker. That's how I'm doing the build for the plug-in now.

@klieber
Copy link
Collaborator

klieber commented Sep 15, 2020

Closing this as headless chrome is the default starting with 3.0-alpha-01. A stable release of 3.0 is coming soon.

@klieber klieber closed this Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants