I have to right click on a particular cell on a HTML table. I have gathered a list of Web Elements (of “td” tag) and can fetch the data and left click on the object. But when trying to use WebUI.rightClick(<>) it says we need to pass a Test Object and not a Web Element.
Kindly let me know how to right click on that particular cell.
There isn’t a way to directly convert from RemoteWebElements (also WebElements or MobileElements) to TestObjects, but we can do it based on some assumptions:
- If the RemoteWebElement was created using xpath
- If Selenium/Appium’s RemoteWebElement.toString() function returns the xpath in the string
First, create a function to get the xpath from the RemoteWebElement:
Thanks Chris. This was extremely helpful.I spent alot of time on this.There is also a lesson to be learned here. When in doubt, use the toString() method to see what text comes out. Once the WebElement is converted to a Sting it’s simple stuff.
Katalon also now includes WebUI.convertWebElementToTestObject() function since 6.2 update. I assume a lot of this discussion has helped with implementing that. I haven’t utilized it much yet to see how it works.