Jenkins is experiencing issues running Selenium scripts on Chrome and Firefox

My configuration includes the Selenium webdriver, along with TESTNG and Maven. I have successfully run tests on IE, Chrome, and Firefox from Eclipse.

However, when I attempt to schedule these tests using Jenkins, they only work on IE and fail on Chrome and Firefox. This issue seems to be related to Selenium Grid.

The log output is as follows:

FAILED CONFIGURATION: @BeforeClass beforeTest  
org.openqa.selenium.WebDriverException: unknown error: unable to discover open pages   (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1 x86_64) 
(Command duration or timeout: 60.77 seconds Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40' System info: host: , os.name: 'Windows 7', os.arch: 'amd64', 
os.version: '6.1', java.version: '1.8.0_91' Driver info: org.openqa.selenium.chrome.ChromeDriver...

Functions

/*********************************************************
* Function: OpenBrowser()
**********************************************************/
public static void openApp(String browserName, String env) throws Exception{
  driver = BrowserFactory.getBrowser(browserName);
  Log.info("Browser:" + browserName);
  driver.manage().window().maximize();
  driver.get(env);
  Log.info("Env: " + env);
  waitForObj.wait(1);
}
public class BrowserFactory  {
  private static Map<String, WebDriver    drivers = new HashMap<String, WebDriver>();
  /*
  * Factory method for getting browsers
  */
  public static WebDriver getBrowser(String browserName) {
    WebDriver driver = null;
    switch (browserName) {
      case "Firefox":
        driver = drivers.get("Firefox");
        if (driver == null) {
          driver = new FirefoxDriver();
          drivers.put("Firefox", driver);
        }
        break;
      case "IE":
        driver = drivers.get("IE");
        if (driver == null) {
          System.setProperty("webdriver.ie.driver", SystemUtils.getUserDir() + "\\drivers\\IEDriverServer.exe");
          driver = new InternetExplorerDriver();
          drivers.put("IE", driver);
        }
      break;
    case "Chrome":
      driver = drivers.get("Chrome");
      if (driver == null) {
          System.out.println(SystemUtils.getUserDir());
          System.setProperty("webdriver.chrome.driver",SystemUtils.getUserDir() + "\\drivers\\chromedriver.exe");
          driver = new ChromeDriver();
          drivers.put("Chrome", driver);
      }
      break;
  }
  return driver;
}

Answer №1

Is Jenkins being used on a virtual machine? Or is it in the same environment where you run your tests locally? If everything works fine running the tests on all web browsers locally, but there are issues when using a VM, it could be because Firefox and Chrome are not installed on the VM.

Answer №2

If you're on Windows, make sure to run your Jenkins services with system admin privileges.

  1. First, open cmd by pressing Win+R
  2. Type "services.msc" and click OK
  3. In the Services dialog box, find Jenkins services and go to its properties
  4. Navigate to the Logon tab and select the second option. Enter your admin user credentials, not the local server's
  5. Finally, restart the services

Following these steps resolved the issue I was facing. Thank you!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for accessing the time in the "2023-04-17" format from the given HTML code with Python Selenium Webdriver

<div class="medium-widget event-widget last"> <div class="shrubbery"> <h2 class="widget-title"> <span aria-hidden="true" class="icon-calendar"></span>Up ...

Unable to extract information from empty <td> using python and selenium

Currently, I am facing an issue while trying to fetch values from a <tr> using Python Selenium. Specifically, I need these values to be ordered and also identified based on whether they contain the word "PICK" or not. My goal is to determine the exa ...

Running tests using Selenium and Maven works fine on a local machine, but encounters an issue in Azure Pipeline with the error message "unable to access org.testng.Assert."

Running TestNG or Maven tests locally shows that all test cases are working correctly. However, when running the tests in a pipeline, an error is encountered stating "cannot access org.testng.Assert". Attached below are error screenshots of Azure Pipeline: ...

When using element(by.binding('...'),getText(), all the content within the element is retrieved, as opposed to just the element itself

Examining the outcome of {{price}} and {{getAdditionalKm}} in my AngularJS Application using Protractor. Here is a snippet of the HTML I aim to test: <h1>{{ price(distance, time, time_standing, airport) | currency }}</h1> <p>Detailed Pr ...

Using Crontab with Pipenv

In short, I'm using Ubuntu 20.04 and need to add a crontab task to run a Python script with pipenv run that includes SELENIUM CHROMEDRIVER. I've attempted the following: 0 9 * * 1-5 @user . cd /home/... ; pipenv run python file.py > /home/.. ...

Exporting table data to a CSV file using Selenium and Python

My goal is to automate the process of extracting my transcript data and saving it to a CSV file using Python with Selenium. I've managed to automate reaching the table page, however, I am facing an issue where only the first row of the table is displa ...

Tips for selecting a button on Yahoo Finance with Selenium

My goal was to automatically extract "quarterly" data from financial reports on Yahoo Finance, but I couldn't figure out how to do it. I initially tried clicking on "the quarterly button" on the financial page (), however, the code below didn't w ...

Tips for extracting HTML text with Python and Selenium

Utilizing Python's Selenium module, I am attempting to extract text and store it in a list or dataframe. Specifically, I am looking to retrieve the text "M" from a class named "flex". Once obtained, I want to input this along with another item into a ...

Utilize Excel information in Selenium by importing and extracting the data for automation purposes

A unique method for seamlessly extracting data from Excel and integrating it into a Selenium script. Utilizing Apache POI, this script efficiently reads the data, saves it to variables, and applies it in practical ways. ...

RobotFramework encountered an unexpected issue - TypeError: WebDriver.__init__() was given an unknown argument 'service_log_path'

Today, I embarked on a journey to set up and utilize RobotFramework for the very first time. Following all the necessary installations, I eagerly wrote a test robot that aimed to simply open Chrome. However, every attempt I made resulted in an error messag ...

Check whether an element is currently in focus with Selenium WebDriver

It's surprising that there doesn't seem to be much information available online about testing for element focus using Selenium Webdriver. I'm interested in verifying that when a form is submitted without filling in a mandatory field, the fo ...

When executing Selenium tests through Jenkins and MSUnit, the browser fails to open, yet the results are still valid

For the purpose of a POC, I have set up a Windows Server 2012R2 machine with Jenkins installed to run Selenium UI tests using msunit. However, during the CI build process (compilation and test execution) on the server where Jenkins is running, I am unable ...

Check for the presence of incorrect information to verify its visibility

My current task involves writing a test in Selenium where I have designated all my web elements in a page object package. To access the web element in my test, I am utilizing S.getColumn(). The getcolumn() function retrieves the web element of the column ...

Having trouble resolving issues with Selenium's Java WebDriver and ChromeDriver?

Hello! I'm encountering an error even after adding all the necessary jar files to the classpath. I have an interview coming up on Monday, so I really need to resolve this issue as soon as possible. My Java version is 21 and Chrome version is 122. Can ...

How to Use Selenium to Locate the Innermost Elements that Contain a Particular Text

Is there a way to retrieve a list of elements from a webpage that contain a specific string without modifying the page's structure? I am currently using Selenium with XPath for evaluation, leveraging the browser-supported XPath engine. Here is a simp ...

Tips for launching and controlling new tabs using selenium

How can I open a new tab with the 'https://www.gmail.com' url, extract some information, and then return to the original page using Python 3.8.5? I am currently opening the new tab with CTRL + t command, but I'm unsure how to switch between ...

Experiencing an intermittent issue with the "JavascriptException" error while using Selenium

Hey, I've encountered something really strange - I'm receiving an error that says "Exception has occurred: JavascriptException / Message: javascript error: this.each is not a function" on a specific line in my code: waiting.until(EC.visibility_of ...

Discovering if an element is currently in the foreground of the DOM by utilizing Java in Selenium

Is there a method to verify if an element is currently in the foreground? https://i.stack.imgur.com/7YOLj.jpg After inputting data into a pop-up window and selecting "Save and Continue", I have implemented checks to determine if the "Cancel" button (High ...

My PyPI installed package is unable to detect the chromedriver file

After creating a python package and publishing it in PyPI, I encountered an issue with the chromedriver selenium code. Despite adding the chromedriver file to the PyPI package folder and specifying the file path in the code as: driver_path= Path.cwd() / &q ...

I have been assigned the responsibility of loading my default chrome profile, accessing the website, and clicking on the extension. However, I am encountering some

After running the code for the first time, I encounter an issue where the website does not load despite opening with extensions. Clicking on Terminate and running it a second time resolves the problem. How can I ensure the code runs successfully on the f ...