object not found when using a variable in keyword test On screen action
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
object not found when using a variable in keyword test On screen action
Hi,
I was trying to find an element and click on it using the keyword test and on screen action. But the object is not found error is displayed.
The variable I am passing here is "ProjectSuite.Variables.i". But the same thing when I use in script mode it is working fine. Not sure what's the problem here.
Aliases.RavenDarttsPge.findElement("(//div[contains(@class,'MuiGrid-root MuiGrid-item') and contains(.,'Available columns')]//div[@role='list']//div[contains(@id,'transfer-list-all-item')])[" + ProjectSuite.Variables.i + "]")
Keyword test
error message
Solved! Go to Solution.
- Labels:
-
Keyword Tests
-
Variables
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can not use variable substitution in XPath query. However, you can do something like this, construct your string first
var xpath = aqString.Format("//div[@role='list']//div[contains(@id,'%s')", ProjectSuite.Variables.i);
where %s will be replaced. Then pass it to,
Aliases.RavenDarttsPge.findElement(xpath)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your tip,
I did not use the aq string, but used the code expression while assigning the variable value as follows and now it works.
