Hi All,
I have gone through the existing discussion on forum related to how to use variables in xpath? and tried the different solutions but, still my script is failed.
I have created a variable in variable tab (variable.jpeg) and used in objects xpath (xpath.jpeg)
Same xpath I have used in script (Test.jpeg) with Click keyword. But, after execution it is showing me the below error in console.
ERROR: [FAILED] - Unable to click on object ‘Object Repository/Bids Page/Request ID’ (Root cause: org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression because of the following error:
SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘’ is not a valid XPath expression.
variable.JPG
xpath.JPG
Test.JPG
Can somebody help me for this issue?
Please copy and paste the code of your test case. I need to see the some lines around:
...WebUI.click(findTestObject('Object Repository/Bids Page/Request ID' .... ...
@4280-kazurayam I’m facing the same issue. I’m using a variable “del” in xpath.
My xpath is as follows:
//td[contains(.,’${del}’)]//preceding-sibling::td//label//input[@type=‘checkbox’]
Norman,
Please tell me the version of Katalon Studio. 5.6.x, 5.7.x or 5.8.x?
Please take screenshot of the Test Object definition. I need to see which Selection Method you chose.
Please show the test case code in script mode. I need to see how you call the findTestObject() method, which is related to the xpath in question.
Version 5.8.6. And thanks for your prompt response.
Test Object definition.png
test case code.png
In the following doc
you find
Parameterizing Web/Mobile Test Object Properties is only available with Basic Attribute Selection Method.
Therefore you need to change the Selection Method first.
At the moment you have
Selection Metod: ●XPath ◎Attribute ◎CSS
Change this to
Selection Metod: ◎XPath ●Attribute ◎CSS
And, as a property of the Attribute selection method , you need to specify xpath manually:
Name | Condition | Value | Detect object by?
xpath | equals | …what you have now …|
Thank you! It’s working now but unable to get the correct data of column from excel file with this approach. Can you help with this?
Please describe your problem with Excel data screenshots, test case code.
I want to delete data(provided via excel file) from the grid(note that the data already exists).
For this purpose I made a variable, and bind the column of excel file with this variable. And finally use this variable in xpath(of Test object). Finally called that test object in my test case. Please find attached screenshots for reference:
4.png
1.png
2.png
5.png
3.png
Noman,
You mentioned
unable to get the correct data of column from excel file
please describe what you found. What data do you expect from excel file, and what data do you get actually. How did you find it? Any error message, or println output?
There is no error faced. However, the values on grid don’t get deleted according to the data of excel file.
When I run the test case, the first row of grid gets deleted every time, irrespective of data of excel.
Moreover, I get the expected result when I use hard-coded value in xpath instead of the above mentioned variable
Let’s check the value of ‘del’ variable. Insert a line of debug-print and see what happens:
WebUI.click(findTestObject('DeleteUoI/Page_PAC ERP LigisticsUnit of Issue/Deletion', [('id'): del]))
WebUI.comment("the value of del variable was \"" + del + "\"")
Please describe what value of the del variable you expect, and what you see in the output from the WebUI.comment.
Good day!
Everything is working now. Thanks for your help. Talk to you in future