Issue
I am trying to dynamically grab an ID that is generated during a workflow and insert it into a locator. If I hard code the value into the locator it works fine. The locator is located inside of a table that is nested inside of an iframe. I am able to manipulate other elements in the table so I don't think it is due to the fact that there is an iframe involved, but I figured it was worth mentioning.
try {
driver.findElement(By.xpath("//table-cell/cell-content/span/a[text()="+**caseID**+"]/../../../../table-cell/cell-content/div/div/div/input[@type='checkbox']")).click();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
System.out.println("unable to select checkbox");
}
The above code is what I am having issues with. The variable being passed to this java class is a string named caseID. I am able to see that the value of the variable is being passed to this class. I can copy the value into this selector and it works fine, but if I add the variable into the locator it can't seem to find it. Any ideas?
Solution
I found the answer to my question by myself.
The issue was fixed by inserting two single quotations around my double quotes see below:
//table-cell/cell-content/span/a[text()='"+caseID+"']/../../../../table-cell/cell-content/div/div/div/input[@type='checkbox']")).click();
I struggled with this way too long, thanks self!
Answered By - Jeremiah
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.