The "xpath" for the url is correct but not visible if added via addProperty

@Katalon Studio

I think @4280-kazurayam deserves a special forum section. B)

2 Likes

Yeah. Me too.

1 Like

kazurayam said:

Andrew,

I thought I can abstract your requirement to a simpler case. You just want to iterate over a elements and elements of a

: 2 dimensional iteration.

Then there is a much simpler approach. You do not need to study org.openqa.selenium.WebElement. You just want to use Parameterized Test Object in Katalon Studio.

The Web Page as testbed is like this:

<html>
foundABC
1A1B1C1
2A2B2C2
3A3B3c3
> ``` > > I made a test case is like this: > > ``` > import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject import com.kms.katalon.core.model.FailureHandling as FailureHandling import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI WebUI.openBrowser('') WebUI.setViewPortSize(703, 347) WebUI.navigateToUrl('http://demoaut-mimic.kazurayam.com/7520_simpler_testbed.html') WebUI.verifyElementPresent(findTestObject('Page_Discussion 7520/table'), 10, FailureHandling.STOP_ON_FAILURE) List<List> expectedContents = [ ["A1", "B1", "C1"], ["A2", "B2", "C2"], ["A3", "B3", "C3"], ] for (int i = 0; i < expectedContents.size(); i++) { for (int j = 0; j < expectedContents[i].size(); j++) { String cellValue = WebUI.getText(findTestObject( 'Page_Discussion 7520/cell', ['trIndex':i + 1, 'tdIndex':j + 1])) WebUI.verifyEqual(expectedContents[i][j], cellValue) } } WebUI.closeBrowser() > ``` > > > I wanted to check if the Web page displays A1, B1, C1, A2, B2, C2, A3, B3, C3 in table as I wrote in the testcase. > > I made a Test Object 'Page_Discussion 7520/cell' like this: > > ![](https://s3.amazonaws.com/katalon-forum/editor/zt/6rnsg6fbmxhz.png) > Please note this Test Object has such XPath as selector: > > > ``` > //table/tbody/tr[${trIndex}]/td[${tdIndex}] > ``` > > > ${trIndex} is the place holder for the index of the elements in the . > ${tdIndex} is the place holder for the index of the . > > These place holders will be interpolated by the Test Case runtime. > When executed, I got following log: > > > > ``` > [INFO] - Found 1 web elements with id: 'Object Repository/Page_Discussion 7520/cell' located by 'By.xpath: //table/tbody/tr[1]/td[1]' in '30' second(s) ... [PASSED] - Text of object 'Object Repository/Page_Discussion 7520/cell' is: 'A1' ... [INFO] - Found 1 web elements with id: 'Object Repository/Page_Discussion 7520/cell' located by 'By.xpath: //table/tbody/tr[1]/td[2]' in '30' second(s) ... [INFO] - Found 1 web elements with id: 'Object Repository/Page_Discussion 7520/cell' located by 'By.xpath: //table/tbody/tr[1]/td[3]' in '30' second(s) ... [PASSED] - Text of object 'Object Repository/Page_Discussion 7520/cell' is: 'C1' ... [INFO] - Found 1 web elements with id: 'Object Repository/Page_Discussion 7520/cell' located by 'By.xpath: //table/tbody/tr[3]/td[3]' in '30' second(s) ... [FAILED] - Unable to verify equal between actual object 'C3' and expected object 'c3' (Root cause: Actual object 'C3' and expected object 'c3' are not equal) > ``` > > > I expected 'C3' but the page displayed 'c3', therefore the test case failed. > > You can clone out this demo form GitHub repository: https://github.com/kazurayam/KatalonDiscussion7520 and see Test Case 'TC2' > > > **\# Disucssion** > > Paremetarizing feature of Test Object is flexible enough; You can make more deeply nested iteration. You can write as many dimensional parameterized XPath expression as you want. > > For example, if you have 2 or more in the target page, you need 3 dimensional parameterized XPath like this: > > ``` > //table[$tblIndex]/tbody/tr[${trIndex}]/td[${tdIndex}] > ``` > > or if you have a table which contains inner tables, you need 4 dimensional parameterized XPath like this: > > ``` > //table[@id="T1"]/tbody/tr[${outerTrIndex}]/td[${outerTdIndex}]//table/tbody/tr[${innerTrIndex}]/td[${innerTdIndex}] > ``` > > > > > > \# Performance issue > > > > The above approach has a performance issue. It make frequent call to WebUI.getText(TestObject). Every single WebUI.getText() makes a request/reply session between Katalon Studio and Browser. It can be very slow. > If you find this approach too slow, then you should look at using > > List WebUI.findWebElements(TestObject) > > https://api-docs.katalon.com/com/kms/katalon/core/webui/keyword/WebUiBuiltInKeywords.html#findWebElements(TestObject,%20int) >

Good Day kazurayam,

Thank you so much!

Actually i was trying all this on my own - tough. I was about 50% thru - so did not even get a chance to get back on the forum.

I am going to try modified approach you recommended above.

Sorry if i am too slow. I am learning as much as i can.

I know words may not reflect much - but just wanted to tell, however people like yourself, Mate and Russ really provide hope and support that allows to progress for new people that trying to learn .

Maybe not at the desired pace.

Don’t know about other newbies - but if someone would tell me 2 months ago when i started with Katalon RECORDER. I found Defect in it and it was not resolved due to some technical difficulties). So I switch to Katalon Studio (and so glad i did so!!!). Manual mode…

Now - i use Katalon Studio with 95% scripting, 2 modules behind and i constantly updating and making sure scripts i added earlier getting modified to be better and working on this 3rd module.

Still probably about 1000 light years behind all of you :slight_smile:

Thank you again & Have a Great Weekend!

Andrew

elements in a

Sorry if i am too slow. I am learning as much as i can.

It’s not a race :slight_smile:

I
know words may not reflect much - but just wanted to tell, however
people like yourself, Mate and Russ really provide hope and support that
allows to progress for new people that trying to learn .

Maybe not at the desired pace.

Repeat after me: It’s not a race!

Don’t
know about other newbies - but if someone would tell me 2 months ago
when i started with Katalon RECORDER. I found Defect in it and it was
not resolved due to some technical difficulties). So I switch to Katalon
Studio (and so glad i did so!!!). Manual mode…

Now
- i use Katalon Studio with 95% scripting, 2 modules behind and i
constantly updating and making sure scripts i added earlier getting
modified to be better and working on this 3rd module.

That, Andrew, is exactly how I work: continuous refinement.

Keep at it. I started using Katalon in February. It’s been a fun ride. B)