How do I click all pages of closed tabs where the value changes when tabs are clicked? (see image below)
Take a script based on this question with the following approach:
clickMe = wait(driver, 10).until( EC.element_to_be_clickable((By.XPATH, path + '[%s]' % str(index - 1))))
Works great for most pages, but I don’t see how this can be used in this case. Any idea how you can get around this problem?
The reason it doesn't work is because as soon as you click on an unopened tab, the values of the numbers change. This means that the task is trying to click on elements that previously existed, but the values of the numbers changed when the closed tab was opened. This is better shown in the image below.
Say you have //div[@class="KambiBC-collapsible-container KambiBC-mod-event-group-container"][1] In the figure below you can see that the above selector will change depending on when the project itself clicks the tabs and when the web page loads. A webpage has the habit of randomizing open and closed tabs. So this explains why it clicks on some elements and then breaks completely, or if you add try except, click only some elements and finish.
exit:
1 2 3 4
Desired
1 2 3 4 etc,, (Clicks all the pages)
The above images:
//div[@class="KambiBC-collapsible-container KambiBC-mod-event-group-container"][1]`
You can see how this will cause problems later. The image on the right cannot find // div [@ class = "KambiBC-collapsible-container KambiBC-mod-event-group-container"] [11], where the one on the left can be based on the order of clicks.
outerhtml
python selenium
user9145009
source share