1

Getting pretty desperate so I thought I'd reach out and see if others had ideas. The application that I'm automating has different forms and each of them open in different tabs within the application (they are not opening in browser tabs,). Many of the elements on the form are shared by the other forms. If I try to interact with an input field or a search button shared on another tab that I had opened in a previous step (even if I'm not focused on the previous form) then I get that the element cannot be interacted with. I'm unable to close the tabs there is no unique identifier for the close buttons on them. I tried to identify the close buttons by the class and use a loop to iterate and close them but that did not seem to work. I know this probably sounds confusing and wild.

3
  • Do you have any control or influence over the selectors? Giving each "tab" a top-level selector would allow you to scope queries to a given section, or using a consistent prefix in a data-testid attribute for the controls in a section.
    – jonrsharpe
    Commented Feb 14, 2021 at 11:57
  • I don't have much control. This is an off the shelf vendor product. It may take too much time to get to my request.
    – sam2013
    Commented Feb 14, 2021 at 15:15
  • Please add html or link to that page
    – PDHide
    Commented Feb 14, 2021 at 16:44

2 Answers 2

1

Define list of web elements and assign all elements with the same identifier to that. Then use the index to reach the exact element. i.e :

@FindBy(id = "testID")
List<WebElement> testList;

or

List<WebElement> testList = driver.findElemets(By.id("testID"));

and then use testList.get(i) which i is the index of the element you want to reach out. Note that indexes start with 0. Of course the locator strategy I used is just a sample and you can use your own.

0

The key to this scenario is to understand xpath or html path for elements in the html document (or webpage) that is display how it is being constructed. There should be some form of grouping done by the application generator. If this has been identified next thing is to construct the FindBy annotation around that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.