The functionality of preserver-order=true is not supported in Selenium Grid

@BeforeTest
@Parameters({"selenium.host", "selenium.port", "selenium.browser", "selenium.url" })
public void startServer(String host, String port, String browser, String url) throws Exception {      
        selenium = new DefaultSelenium(host, Integer.parseInt(port), browser, url);
        selenium.start();
    }

testng.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="SL-Grid" parallel="false">

    <parameter name="username" value="test" />
    <parameter name="password" value="test1" /> 

<test name="SL-Chrome" preserve-order="true"> 
    <parameter name="selenium.host" value="localhost"></parameter> 
        <parameter name="selenium.port" value="5555"></parameter> 
        <parameter name="selenium.browser" value="*googlechrome"></parameter> 
        <parameter name="selenium.url" value="http://properurl:8080/"></parameter> 
        <classes>
            <class name="com.TestBase" /> // Base class where all generic methods, setUp and tearDown methods present
            <class name="com.Login"> // Login related methods and inherit TestBase
                <methods>
                    <include name="loginPage" />
                    <include name="signIn" />
                </methods>
            </class>
            <class name="com.Page1">
                <methods>               
                    <include name="clickLinkA" />
                    <include name="isTextBoxXXXPresent" />
</methods> </class></classes></test>

<test name="SL-Firefox" preserve-order="true"> 
    <parameter name="selenium.host" value="172.16.4.21"></parameter> 
        <parameter name="selenium.port" value="5556"></parameter> 
        <parameter name="selenium.browser" value="*firefox"></parameter> 
        <parameter name="selenium.url" value="http://properurl:8080/"></parameter> 
        <classes>
            <class name="com.TestBase" /> // Base class where all generic methods, setUp and tearDown methods present
            <class name="com.Login"> // Login related methods and inherit TestBase
                <methods>
                    <include name="loginPage" />
                    <include name="signIn" />
                </methods>
            </class>
            <class name="com.Page2">
                <methods>               
                    <include name="clickLinkB" />
                    <include name="isListBoxXXXPresent" />
</methods> </class></classes></test>

</suite>

Upon running the suite, it is expected to invoke startServer() from TestBase -> loginPage() and SignIn() from Login -> clickLinkA() and isTextBoxXXXPresent() from Page1. However, sometimes the system initiates methods from Page1 class first, resulting in failure (as signIn is not invoked).

If you have any insights on what might be going wrong here or better ways to design this process, or any alternatives to preserve-order, please feel free to share.

Answer №1

It seems like there may be an issue with TestNG that you should consider reporting to the TestNG team. One way to overcome this issue is by including your login and signin method in the BeforeTest or calling it directly in your test Method, particularly in the clickLinkA scenario. Hopefully, this solution resolves your problem.

Answer №2

Utilize the dependsOnMethods feature to ensure sequential execution of tests where one test relies on the outcome of another. Additionally, you can establish a priority order by assigning numeric values, with lower numbers indicating higher priority. By default, tests have a priority of 0, so only tests with differing priorities need explicit assignment for proper sequencing.

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

I am searching for the xpath that corresponds to the image

This here is the html code <div class="navBg"> <table id="topnav" class="navTable" cellspacing="0" cellpadding="0" style="-moz-user- select: none; cursor: default;"> <tbody> <tr> <td class="logoCell" valign="top"> < ...

Text successfully inserted into the input field using Xpath

I need help with the following issue: I am trying to use Selenium to verify if an input field contains a specific text that has been manually entered. Here is an example of an input field with the value '50': <input type="text" class="value ...

Discovering xpath in Chrome Version 58.0.3029.81 (64-bit) can be done effortlessly with the help of xpathfinder. Unfortunately, the shortcut shift+ctrl+x

Having trouble locating the xpath in Google Chrome Version 58.0.3029.81 (64-bit) using xpathfinder. The shortcut shift+ctrl+x is not working for this. This xpath would be used with selenium 3.3.1 for automation testing. Your assistance is greatly appreci ...

A guide on utilizing Selenium to choose an option within a dropdown menu featuring an AJAX onchange attribute

After browsing several pages on stackoverflow, I have not been able to find a solution to my current problem. My goal is to automate a work process using selenium (python). This process requires logging into a web portal, selecting specific search criteria ...

Tips on shifting the focus of Selenium to a newly opened tab?

When I click on a link, it opens in a new tab. My goal is to switch to that tab, close it, and then return to the original parent window. I've tried the following code but encountered an error. It seems like the control is not moving to the child win ...

Utilizing a Distinctive Profile in Selenium: A Step-by-

I am currently attempting to utilize a specific Profile within my Chrome Browser. To do so, I am aware that I must utilize the user-data-dir flag and specify the path to my desired Profile. For instance, let's assume I have a Profile named Profile 1 ...

Is it Feasible to Use Accumulators in XPath with Python?

Is it feasible to perform an accumulation in XPath? Take a look at my code: driver = webdriver.Chrome() driver.get('http://www.imdb.com/user/ur33778891/watchlist?ref_=wt_nv_wl_all_0') wait = (WebDriverWait, 10) x = 1 while True: try: ...

Jenkins is having trouble running Selenium tests with the FirefoxDriver, even though they work perfectly on a local desktop setup

I am currently facing an issue while trying to execute my Selenium tests in Jenkins. These tests are running smoothly on my local machine using Maven test or IntelliJ. Here is the setup I am using: Firefox 39 x64 Selenium 2.46.0 SeleniumHQ pl ...

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 ...

Selenium: The Hunt for the Absent Get Methods

When trying to use the GetAttribute or GetText methods in Selenium, I am unable to find them. For example, there is a Forgotten Password link with instructions above it to click the button if password is forgotten. I wanted to use GetText, but that option ...

What is the best way to create a report.html file for each testsuit (.robot file) in RoboTFramework?

Currently, I am utilizing a single PyCharm project to execute various test files for a specific website. For instance, I have robot files containing test cases like: loginTest.robot, purchasetest.robot, signinwith_facebook.robot However, whenever I run t ...

The dropdown list is nowhere to be found in the page source when using Selenium

Currently, I am engaged in web scraping using Selenium. Successfully locating the input box and entering ID numbers is no issue. Yet, a roadblock presents itself - there is no submit button linked to the search bar. Once the numbers are inputted, the box a ...

Webdriver issue in FireFox browser

My python code is having trouble finding the geckodriver. import time from selenium import webdriver browser=webdriver.Firefox('D:/Folder_1/chrome_driver/geckodriver_win32/geckodriver.exe') An error message is showing: WindowsError: [Error 267] ...

Error encountered while using JavaScript for waiting in Selenium

When using selenium and phantomjs to submit a form and then navigate back to the previous page, sometimes I encounter a timeout error as shown below: TimeoutError: Waiting for element to be located By(xpath,//div[@id='ContactFormBody']/div/br) W ...

What is the best way to manage a situation where a web element is removed from the DOM while using Selenium Web

On the Sign In page of , I am struggling to extract the value of a label identified by the xpath=".//*[@id='msgIdmmrka']." This particular web element disappears from the DOM a few seconds after entering no email address, a valid password, and cl ...

Leveraging DataProvider in TestNG with a single instantiation of WebDriver

Trying to validate the login page control using a data provider without reinitializing the webdriver for each username and password input. I want to check all relevant scenarios on the login page at once without restarting another driver. However, I'm ...

Every time I try to run my scripts on PyCharm using Jenkins, I keep receiving a notification to

While attempting to execute automated tests on the cloud version of Jenkins, I encountered the following error: Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-0739wibs/cryptograph ...

The dynamic dropdown on https://www.nseindia.com/ does not display auto-suggestions when Selenium and Python are used to pass values

driver = webdriver.Chrome('C:/Workspace/Development/chromedriver.exe') driver.get('https://www.nseindia.com/companies-listing/corporate-filings-actions') inputbox = driver.find_element_by_xpath('/html/body/div[7]/div[1]/div/section ...

Error message: "Execution of taskkill executable not found in Selenium WebDriver"

Every time I run the driver.quit() command, it successfully opens and quits the firefox browser but I keep getting an error message saying "Unable to find executable for: taskkill". I have already set the environment variable PATH to "C:\Windows&bso ...

WebDriverException was encountered while attempting to establish a connection with localhost/0:0:0:0:0:0:0:1:1941 using GeckoDriver and Selenium due to a java.net.ConnectException

I am currently facing an issue while trying to set up Eclipse for writing a basic automated test. Specifically, I am encountering difficulties in launching Firefox. Below is the code I have written along with the error stack that follows: Here's the ...