I wonder if anyone knows how to save an attribute for an object and reuse it later when the object has changed location?
What I do first is to lokate the object on top of a grid view, click on it and press submit.
This is done by:
And selenium will automatically choose the top located object, unfold the object and make it possible for me to press the submit button.
I have also figured out how to get the unique identifier for that object which is by typing:
Since the unique identifier is a title in this case.
So my question is how do I write a code that saves the title and clicks on it / that specific object one it has been relocated. It is very important that this code is reusable since the objects in the grid view will have different titles.
The only unique identifier I have is a title.
I solved the issue by creating a string with the css selector + the variable + the ending of a css selector. this means that i declared a string for the title and got it by using
String title = driver.findElement(By.cssSelector(xxxxxxxx)).getAttribute("title"); title = mydeclaredstring;
In test cas Nr 2 i created a string by
String titleString = "css[selector='" +mydeclaredstring + "']"