Jenkins with Selenium 3, Chrome Driver latest version and Chromium Browser on cheap 32bit Linux

What a lovely day it has been in Wellington. Finally there comes the summer! And I also have a lovely day to successfully make stable test results on 32bit Ubuntu Linux with Chromium Browser, latest ChromeDriver and new Selenium java 3.1.0!

Jenkins on bandwagon

http://jenkins.maxwu.me/job/Cucumber_Jvm_Selenium_Toy/

By the way, the last issue is fixed after a lovely walk from Petone seaview trail~ This site was originated as a pure technical sharing place but I hope I can make an exception to share the photo from Petone beach. Good weather sweeps away the raining feelings on another disappointing call.

Upgrade to Selenium 3.1.0

After upgrading from selenium-java 3.0.1 to 3.1.0 (Feb 2017 recently released), there reported a method resolving issue on wait.until() in below code block.

By byDiv = By.cssSelector("div#resultStats");
WebDriverWait wait = new WebDriverWait(dr, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(byDiv));

The solution is to manually add missing dependency on google guava library. Update pom.xml in maven to adapt this dependency will resolve it.

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
</dependency>

Github issue link

Chrome on 32bit Linux

Since the installation and setting up on MBP is smoothy within 1 hour, there was an underestimation on making it happen with 32bit Linux. Which finally absorbed two half-days in the afternoon. To make things easy, I freshed the VPS with Ubuntu 14.04 and deleted the origina CentOS first. So SS service is terminated, which will be restored next week.

  • Google didn’t support 32bit Linux from Feb 2016. The latest version archived on internet is 48.0.2564.116-1_i386.
  • But ChromeDriver requests a higher browser version if picking up latest version (2.27) with stability fixes.
  • My VPS is on bandwagon with a low price plan (<10USD per year) lasted for couple of years. It offers 512Mb memory and 32bit Celeron CPU.

Solution:

  • Install chromium instead of chrome-browser. Chromium is an open source cummunity maintained lively version as an alternative to official Google Chrome. It supports 32bit Linux distribution.

  • Special tips:

    • With Ubuntu defaul source list, the latest version is Chromium 53.0.2785.14. Which is still not the latest binary.

    • Update with below source, the latest chromium-browser version is Chromium 55.0.2883.

      sudo add-apt-repository ppa:saiarcot895/chromium-dev 
      sudo apt-get update
    • Specify chromium binary to browser driver. The absolute path to chromium-browser executable is for my Ubuntu 14 with installation on ppa channel. You may replace with your own path to chromium.

      options = new ChromeOptions();
      //..
      options.setBinary(new File("/usr/bin/chromium-browser"));
      //..
      WebDriver driver = new ChromeDriver(options);

Chrome tap crash

The chrome tap crash happens on 32bit Ubuntu 14 Linux.

Failure in before hook:TemperatureConverterPageStepDef.setUp(Scenario)
Message: org.openqa.selenium.NoSuchSessionException: no such session
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Linux 2.6.32-042stab120.18 x86) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 14 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'maxwu', ip: '104.224.136.48', os.name: 'Linux', os.arch: 'i386', os.version: '2.6.32-042stab120.18', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=session not created exception
from tab crashed
(Session info: chrome=48.0.2564.116)
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Linux 2.6.32-042stab120.18 x86), platform=ANY}]
Session ID: 55d40b642a275ba583eb6ee9e6d53d31
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

This issue is severer after upgrading ChromeDriver to 2.22+ versions. There are some suspicious clues but none is confirmed. Finally after performing a series of branches tests and analysis, the solution is to move driver.manage().window().maximize(); to chrome start options as below.

options = new ChromeOptions();
// To fix browser crash issue
options.addArguments("--start-maximized");
ChromeDriverManager.getInstance().setup();
WebDriver driver = (null==options)? new ChromeDriver(): new ChromeDriver(options);

Github Issue Link

Chrome Browser Hanging-up

Browser hanging-up randomly happens more frequently than other stability issues and it is the actual high runner among others. The frequency shows Private Jenkins > Travis-CI >> Circle-CI. CircleCI is much better stable comparing to Travis-CI on chrome-browser web testing.

On private Jenkins we could read the log that browser hanging-up for a long time. On travis-CI, if the building execution has no output in 10 minutes, the docker monitor will shut down the task and lable a failure (terminated) on records.

org.openqa.selenium.TimeoutException: timeout: cannot determine loading status
from timeout: Timed out receiving message from renderer: -600.008
(Session info: chrome=55.0.2883.11)
(Driver info: chromedriver=2.25.426927 (d0803376130bda68eb594d02ebaca4609e3f899e),platform=Linux 2.6.32-042stab120.18 x86) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 900.74 seconds
Build info: version: '3.1.0', revision: 'b94c902', time: '2017-02-16 12:21:31 -0800'
System info: host: 'jenkins', ip: '104.224.136.48', os.name: 'Linux', os.arch: 'i386', os.version: '2.6.32-042stab120.18', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426927 (d0803376130bda68eb594d02ebaca4609e3f899e), userDataDir=/tmp/.org.chromium.Chromium.auFTt4}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=55.0.2883.11, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 64463c793b65a1f95383edd756abda17

There are multiple possible triggers to cause a stuck, loading some plugin, flash content streaming, waiting for some default AD scripts, DNS prefetching (TTL), security check on plugins, … Here the working solution plan just mitigate as many as it can and it brings the CI back to healthy status. Once there is a new unstable element being introduced, the recommendation is to do a preliminary check if the action or configuration can be done by Options object instead of any direction action through ChromeDriver.

options = new ChromeOptions();
// ..
// To fix browser hanging-up issue
options.addArguments("--dns-prefetch-disable");
options.addArguments("--always-authorize-plugins");
ChromeDriverManager.getInstance().setup();
WebDriver driver = new ChromeDriver(options);

This Issue Link

TODO: fetch statistic data with new lib ci-stat

Embedded Status Badge from Jenkins

This step is simple. From the Jenkins console, install embedded jenkins status and place the links into README.md on github master branch. The status badge in third line of below snapshot is Jenkins status icon from the private jenkins on http://jenkins.maxwu.me

Jenkins Status Badge

Setup xvfb for Jenkins

Either vncserver or xvfb works here to initialize the x-window display for browser. If headless browsers are utilized, this step is not necessary.

Install the xvfb plugin for Jenkins. There is a special hint:

  • xvfb needs at least a manual configuration step on Jenkins before working. This step will create the necessary configuration records for Jenkins to start before each CI task and end after it.

  • The menu path is Manage Jenkins -> Global Tool Configuration -> XvFb, not on Jenkins Configuration.

Notes: Recent Firefox and Chrome offers headless mode. Which is faster and XWin display or xvfb is no longer needed. Firefox starts to support headless mode from version 56 on Mac. Current stable version on Mac is v55 but beta version is 56b. New developer version is based on v57.

Jenkins on Mac

It is convenient to install Jenkins on Mac. brew install jenkins will install and setup Jenkins quickly. The jenkins was installed as a service with brew.

>brew services start jenkins
>brew services stop jenkins

Jenkins on MacBookPro

Other setup actions as coverage status with

Updated Feb 23, 2017

Drafted Feb 21, 2017

------ End ------
Max Wu wechat
微信 WeiXin

热评文章