For the moment, I'm looking to make a program for a repetitive action which we need to make something like 1000 times by hand otherwise.
This action is done throughout a web browser (I'm using Chrome). My actual issue is the XPATH selector is changing at every connection but only one number. So, I use the recognition on the webpage linked using Selenium and associated WebDrivers.
The fact is my code run sometimes when the selector has the right name.
Indeed, as the css selector is changing permanently, it happens that this is the right one !
So, after making a headless browser, login to the company webpage, I have to recognize then click on a specific object on the navigator :
The problematic code is the following:
wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="__xmlview0--settingsButton-img"]')))
OT = driver.find_element_by_xpath('//*[@id="__xmlview0--settingsButton-img"]')
OT.click()
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '#__select1-label')))
driver.save_screenshot("screenshot.png")
I have an idea but I don't know how to do it: Is it possible to add a random number instead of the 0 in xmlview0
, which is the number issue within the CSS selector ?
I'm not a Python veteran and I really don't want to do the job by hand.