Just a bit of an explanation. The “byXPath” in your code above is a method that allows you to create a Test Object by supplying an xpath, so we don’t need the “driver” reference. How about the below:
The “properties” is the pathway (the xpath) provided to the byXPath method.
Does the pathway "//*[@id='mlist']/tbody/tr[1]/td[3]/div/span" exist? The upper error message states that the pathway has a problem. Are you trying on two different environments? Are the builds the same?
You already know how to loop to find one item (like the name), such as “Fadela Haddadi {Main}” and you were able to do that with a “parameterized” rowIndex. So the rowIndex of the “Employee Id” would be the exact same, but the column, or “td” element, would be different–and you know which column it is (you can hardcode this column). There you go. Put the two concepts together.
What can we do to tackle this issue? Can you please download the true build and see if you are getting the names and it gets the expected name, let’s say Fadela Haddadi {Main} ?
You wrote you are using two environments. I guess, one is a development environment, which has small amount of data, which responds quickly. Another environment is a production environment, which has full of data, which responds slowly (you need to wait for a few seconds). Your script happened to run OK against the dev env, but it fails against the prod env. Why?
This is a Frequently Asked Question in this forum.
Any web app needs certain duration of milli-seconds to respond. Web app responds slower than your test script runs. Especially, the document inside <iframe> would require several seconds to load because it is loaded from another URL.
Therefore your script must cope with the slowness of your Application Under Test. Your test script must wait for the HTML pages are completely loaded into browser before it makes any action against the page.
You need to lear how to use “WebUI.verifyXXXX(TestObject, timeout)” and “WebUI.waitForXXXX(TestObject, timeout)” keywords. For example
The idea of “contains” is to get a smaller bit of the whole. If you are going to compare to the whole, then perhaps use:
if (theName == "Scott Backhouse {Main}") {
Saying that, there are a lot of ways that you can use “contains”, like:
if (theName.contains("Scott Backhouse")) {
Also, since you are having concerns about finding the name, you should make a print out of the names so you can see if there is something else in the “cell” that you have not realized, such as a non-printable character, including getting the correct column
println("Name is ${theName}")
if (theName.contains("Scott Backhouse")) {