How do I click all the unopened tabs pages where the value changes when you click tabs? (see image below)
Take the following script, based off of 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 the large majority of pages, however I cannot see how it can be used in this case. Any idea how you can get around this issue?
The reason it does not work is because as soon as you click an unopened tab, the number values change. This means the job is trying to click elements that used to exist, but the number values changed when you opened a closed tab. This is better illustrated in the image below.
Say you had //div[@class="KambiBC-collapsible-container KambiBC-mod-event-group-container"][1]
In the picture below, you can see that the above selector will change based upon when the job itself clicks tabs and upon loading the webpage. The webpage has a habit of randomising opened and closed tabs. So this explains why it will click some elements and then completely break or if you add try except, click only some elements and finish.
output:
1
2
3
4
#Stops working
Desired
1
2
3
4
etc,, (Clicks all the pages)
The above images are both:
//div[@class="KambiBC-collapsible-container KambiBC-mod-event-group-container"][1]`
You can see how this will cause issues later on. The image on the right would not be able to locate //div[@class="KambiBC-collapsible-container KambiBC-mod-event-group-container"][11] where a the one on the left could based on the order of tabs clicked.
outerhtml