What you need before start
- JDK 1.7 (not JRE!)
- Git
Also, make sure you have your jdk in you path, which means you can run commands like 'jar' or 'javac' in your dos/shell prompt.
Get Selenium Source code
There are 2 ways to get source code. You can choose any one you like.
- Method 1: git clone
// clone the source from github git clone https://github.com/SeleniumHQ/selenium selenium_git // List all tag git tag –l //checkout a certain tag (version), here is 'selenium-2.40.0' git checkout tags/selenium-2.40.0
- Method 2: download zipped source package (recommend if you don't have a stable internet connection)
- Go to https://code.google.com/p/selenium/source/browse/
- Choose the version/tag you need.
- click "zip" or "tar.gz" to download an all-in-one package
- unzip the downloaded file to a local directory. For this example I build selenium on windows, the directory I use for unpacking is d:\selenium_src. The directory will look like below.
- make the directory a git repository to make build script happy. Since the build script will call git command, it will report error if the source directory is not a git repository.
// go to selenium source dir cd d:\selenium_src // make it a git repository git init
Download 3rd party library (recommend but optional)
The build script of selenium will automatically download the third party gecko library. So this step is optional, but If you have a trouble while compiling or have a slow or unstable connection. I suggest you download the libraries manually to make your life easier.
- Go to these places:
- Download the file respectively:
xulrunner-17.0.en-US.win32.sdk.zip
xulrunner-24.0.en-US.win32.sdk.zip
xulrunner-26.0.en-US.win32.sdk.zip
xulrunner-27.0.en-US.win32.sdk.zip
Notice: you need to pick up the file for your platform. Since I'm using windows, I download the win32 sdk. If you're in linux, choose the linux version sdk instead.- Unpack all SDKs to selenium gecko-xx dir
For example the content of sdk xulrunner-17.0.en-US.win32.sdk.zip goes to selenium_src\third_party\gecko-17\win32.
Notice: when unzip the sdk package, remove the top level direcory in the zip file. The final directory hierarchy will look like this:
Run the build script ( 3 go commands )
Run the build script# change to selenium source root cd d:\selenium_src # clean go clean # compile the source code go //java/server/src/org/openqa/selenium/remote/server:server:uber //java/client/src/org/openqa/selenium:client-combined:uber # make the standalone jar go release
If everything goes fine, you can find your selenium standalone jar file in dir <selenium source root>/build/dist like below
I'm getting a "fatal: Needed a single revision" error when compiling :(
ReplyDeleteIt happens after this command:
Compiling: //java/client/src/org/openqa/selenium/firefox:firefox as build\java\c
lient\src\org\openqa\selenium\firefox\firefox.jar
Uber-jar: //java/server/src/org/openqa/selenium/remote/server:server as build\ja
va\server\src\org\openqa\selenium\remote\server\server-standalone.jar
fatal: Needed a single revision
Hi Stephen,
DeleteThere "fatal: Needed a single revision" messages come out from git. It becauses you may have .git directory in selenium source directory but have not specified a version to work on. There message will not break the compile process. If you just want to get the standalone executable jar file, you can just ignore the messages.
It's not that "fatal" :D
This comment has been removed by a blog administrator.
ReplyDeleteI have to delete the comment due to the over length, make sure JDK has been properly install before compiling.
DeleteSimple Good and better thing it works perfectly ..Helped me alot thanks :)
ReplyDeleteI get a lot of "The system cannot find the path specified." when building, then it falls back to prebuild files. Then it aborts with this message "'jar' is not recognized as an internal or external command"
ReplyDeleteBuild no longer aborts, after adding correct SDK to the Path. I still see js files being skipped when compiling, and the file I need to change is skipped and falls back to recompiled.
DeleteHI,
ReplyDeleteI have followed the above mentioned steps for building the selenium source code in the linux machine.
When I ran the below command
./go clean
I got below error
fatal: Unable to mark file cpp/prebuilt/amd64/libimehandler64.so
fatal: Unable to mark file cpp/iedriver/Generated/atoms.h
It will be great if any one help me in this..
Thanks in Advance
Thank you very much, you saved my day.
ReplyDelete