Jaquline,
Thank you for additional screenshot.
I can not find ‘BAIC’ and ‘BMW’ in the document node tree. Do you have any idea why? Where is the text ‘BAIC’?
Jaquline,
Thank you for additional screenshot.
I can not find ‘BAIC’ and ‘BMW’ in the document node tree. Do you have any idea why? Where is the text ‘BAIC’?
kazurayam said:
Jaquline,
Thank you for additional screenshot.
I can not find ‘BAIC’ and ‘BMW’ in the document node tree. Do you have any idea why? Where is the text ‘BAIC’?
Jaqueline,
I made a running example. Please have a look at this:
https://github.com/kazurayam/KatalonDiscussionComment14771
I made a Test Object like this:
//ul[@id='ManufacturerList_listbox']/li[@data-offset-index='${index}']
I made a Test Case like this:
WebUI.openBrowser('')WebUI.navigateToUrl('http://demoaut-mimic.kazurayam.com/comment14771_testbed.html')// The target page is Ajax-driven. Page is dynamically updated by JavaScript.
// We need to wait for some microseconds until the page become completed.
// Let's wait for the '- Please Select -' text become visible.
WebUI.waitForElementVisible(
findTestObject('Page_14771/li_- Please Select -'), 20)def contentA = WebUI.getText(
findTestObject('Page_14771/li_- Please Select -'))
WebUI.verifyEqual(contentA, '- Please Select -')def contentB = WebUI.getText(
findTestObject('Page_14771/li_ManufacturerList_BAIC'))
WebUI.verifyEqual(contentB, 'BAIC')def content1 = WebUI.getText(
findTestObject('Page_14771/li_ManufacturerList_parameterized',
['index':'1']))
WebUI.verifyEqual(content1, 'BAIC')def content2 = WebUI.getText(findTestObject(
'Page_14771/li_ManufacturerList_parameterized',
['index':'2']))
WebUI.verifyEqual(content2, 'BMW')// If we want to know the size of the ManufacturerList,
// look at the data-offset-index attribute of the last <li> element.
def lastIndex = WebUI.getAttribute(
findTestObject('Page_14771/li_ManufacturerList_last'),
'data-offset-index')
WebUI.verifyEqual(lastIndex, '4')WebUI.closeBrowser()
You mentioned you are suffering from message “Element not visible”. Most probably that is because your Application-Under-Test is a Ajax-driven website where HTML is dynamically updated by JavaScript in the browsers. In order for the Test Case run in sync with Ajax-processing, the Test Case should wait for the target element become visible. This synchronization is done by this line:
WebUI.waitForElementVisible(
findTestObject('Page_14771/li_- Please Select -'), 20)
kazurayam said:
Jaqueline,
I made a running example. Please have a look at this:
https://github.com/kazurayam/KatalonDiscussionComment14771I made a Test Object like this:
//ul[@id='ManufacturerList_listbox']/li[@data-offset-index='${index}']
I made a Test Case like this:
WebUI.openBrowser('')WebUI.navigateToUrl('http://demoaut-mimic.kazurayam.com/comment14771_testbed.html')// The target page is Ajax-driven which page is dynamically updated by JavaScript.
// We need to wait until the page is displayed.
// Let’s wait for ‘- Please Select -’ become visible.
WebUI.waitForElementVisible(
findTestObject(‘Page_14771/li_- Please Select -’), 20)def contentA = WebUI.getText(
findTestObject(‘Page_14771/li_- Please Select -’))
WebUI.verifyEqual(contentA, ‘- Please Select -’)def contentB = WebUI.getText(
findTestObject(‘Page_14771/li_ManufacturerList_BAIC’))
WebUI.verifyEqual(contentB, ‘BAIC’)def content1 = WebUI.getText(
findTestObject(‘Page_14771/li_ManufacturerList_parameterized’,
[‘index’:‘1’]))
WebUI.verifyEqual(content1, ‘BAIC’)def content2 = WebUI.getText(findTestObject(
‘Page_14771/li_ManufacturerList_parameterized’,
[‘index’:‘2’]))
WebUI.verifyEqual(content2, ‘BMW’)// If we want to know the size of the ManufacturerList,
// look at the data-offset-index attribute of the last
You mentioned you are suffering from message "Element not visible". That is because your Application-Under-Test is a Ajax-driven website where HTML is dynamically updated by JavaScript in the browsers. In order for the Test Case run in sync with Ajax-processing, the Test Case should wait for the target element become visible. This synchronization is done by this line:
WebUI.waitForElementVisible(
findTestObject(‘Page_14771/li_- Please Select -’), 20)
Hi,
Just asking may I know what should be the xPath for these test objects also? Thanks.
Just asking may I know what should be the xPath for these test objects also? Thanks.
You can find them here:
kazurayam said:
Just asking may I know what should be the xPath for these test objects also? Thanks.
You can find them here:
https://github.com/kazurayam/KatalonDiscussionComment14771/tree/master/Object%20Repository/Page_14771
Hi,
I’ve got these errors when I run the script:
1. Object ‘Object Repository/Page_Supplier Label Printing/li_- Please Select -’ is not visible after 20 second(s)
2. Unable to verify equal between actual object ‘’ and expected object ‘- Please Select -’ (Root cause: Actual object ‘’ and expected object ‘- Please Select -’ are not equal)
3. Test Cases/Create Preference FAILED because (of) Unable to verify equal between actual object ‘’ and expected object ‘- Please Select -’ (Root cause: Actual object ‘’ and expected object ‘- Please Select -’ are not equal)
Jacqueline,
1. Object ‘Object Repository/Page_Supplier Label Printing/li_- Please Select -’ is not visible after 20 second(s)
I am sorry, I can not investigate this because I do not have access to your Web app.
Let me tell you what, I presume, is happening in your Web app.
When the target page is loaded and opened on browser window, the ul[@id=‘ManufacturersList_listbox’] element is empty (no BAIC there, no BMW in the list). After that when you click or move mouse over some HTML element, JavaScript reacts to fill the list with the names of manufacturers. This is the way how AJAX web pages works. A Ajax-driven web page transforms itself in response to the human action (click, mouse over, etc). Possibly your Test Case lacks triggering AJAX processing. Therefore the ManufacturersList actually is left empty. So that the test case finds that the “li_- Please Select -” object is not visible after 20 seconds.
Possibly you need to
In order to accomplish this, you need to observe your Web page in depth and find out how the page works. Only those who have unrestricted access to the Application-Under-Test would be able to solve this sort of problem. AJAX-driven Web app is easy for visitors but is hard to test.
Hi Kazurayam,
I think you are right with the explanation. So, the workaround that I did is to click on the element first followed by waiting for the element to be visible then click on the chosen element “BAIC”. And it works! Thanks for your help.
kazurayam said:
Tamanna,
Please find my proposal :
GitHub - kazurayam/KatalonDiscussion14605: parameterized Test ObjectI assumed that your HTML has such lines:
<select name="something">
<option id="ui-select-choices-row-88-234">
<span class="ui-select-choices-row-inner" uis-translude-append>
<div ng-transclude="item" class="ng-score">
<div ng-bind-html="item[vm.labelField]" class="ng-binding">foo</div>
</div>
</span>
</option>
<option id="ui-select-choices-row-99-3">
<span class="ui-select-choices-row-inner" uis-translude-append>
<div ng-transclude="item" class="ng-score">
<div ng-bind-html="item[vm.labelField]" class="ng-binding">bar</div>
</div>
</span>
</option>
<option id="ui-select-choices-row-24-2">
<span class="ui-select-choices-row-inner" uis-translude-append>
<div ng-transclude="item" class="ng-score">
<div ng-bind-html="item[vm.labelField]" class="ng-binding">Alternative Dispute Resolution</div>
</div>
</span>
</option>
> ```
>
> And I assumed that you want to grasp the element with id "ui-select-choices-row-24-2", you want to abstract 24 portion, and you want to regard 2 as the key for lookup.
>
> I made a test object which as a locator as follows:
>
> ```
> //option[starts-with(@id,'ui-select-choices-row-') and substring-after(substring-after(@id,'ui-select-choices-row-'),'-')="${index}"]
> ```
>
> Well, it is a bit complicated. This is a valid XPath expression. It just works. It is inevitably complicated because your requirement deserves.
>
> My test case has following lines:
>
> ```
> def content = WebUI.getText(findTestObject('Page_14605/option_with_param', ['index':'2']))
WebUI.verifyEqual(content, 'Alternative Dispute Resolution')
> ```
>
> This test case runs successful.
>
>
Why does this model not fit in obj by Xpath
‘By.xpath’ ? Why does it appear here? I do not understand.
Please take the screenshot of the Test Object “Ojbect Repository/Page_/label_parameterized” and show it.
kazurayam said:
‘By.xpath’ ? Why does it appear here? I do not understand.
Please take the screenshot of the Test Object “Ojbect Repository/Page_/label_parameterized” and show it.
I changed your way,Trying to assign variables in Xpath
Please have a look at:
https://docs.katalon.com/pages/viewpage.action?pageId=12419075
This page is a bit outdated.
Warning
Parameterizing Web/Mobile Test Object Properties is only available with Basic Selection Method.
As for version 5.7.0, this sentence should be rewritten:
Warning
Parameterizing Web/Mobile Test Object Properties is only available with Attribute Selection Method.
Jester,
Your test object has ‘XPath’ as selection method. This would not accept parameter ${index} ---- I suppose, I have not checked it myself, I may be wrong.
Try changing the selection method from XPath to Attribute, and retry.
kazurayam said:
Please have a look at:
https://docs.katalon.com/pages/viewpage.action?pageId=12419075This page is a bit outdated.
Warning
Parameterizing Web/Mobile Test Object Properties is only available with Basic Selection Method.As for version 5.7.0, this sentence should be rewritten:
Warning
Parameterizing Web/Mobile Test Object Properties is only available with Attribute Selection Method.Jester,
Your test object has ‘XPath’ as selection method. This would not accept parameter ${index} ---- I suppose, I have not checked it myself, I may be wrong.
Try changing the selection method from XPath to Attribute, and retry.
yeah,ojb by Attribute way is ok,But sometimes I have to find obj by Xpath,and i have to copy a right xpath to the Attribute mesthod (like jpg), This’s too much trouble.it’s not cool
thank you for your help!
If you have a better way, please contact me.
谢谢!