I have just started to learn python and tried to make a little project where I do some interaction with a website, but I have a little problem and I am not able to solve it myself.
I am trying to find some stuff on a website. Therefore I enter some criteria and press then the search button. If my search is successful, new information appears on the website and I would like to hit a button, do some other actions and go back to the search side. If there is no result, I go back to the search site.
The code works fine for most of the time, but sometimes I receive an error and my code interrupts.
#click search button
css = 'button.btn-standard:nth-child(2)'
iElement = browser.find_element_by_css_selector(css)
iElement.click()
#wait some time
t = random.uniform(0.190, 0.25)
time.sleep(t)
css = 'body > main > section > section > div.ut-navigation-container-view--content > div > div > section.ut-navigation-container-view.ui-layout-right > div > div > div.DetailPanel > div.bidOptions > button.btn-standard.buyButton.currency-coins'
try:
#Check if search is successful
iElements = browser.find_element_by_css_selector(css)
#Buy now for n coins
iElement = browser.find_element_by_css_selector(css)
iElement.click() # <- here is were the error occurs
.... some other code that works...
except NoSuchElementException:
a = 1
#Go back
css = '.ut-navigation-button-control'
iElement = browser.find_element_by_css_selector(css)
iElement.click()
Error: ElementClickInterceptedException: Message: Element is not clickable at point (972,569) because another element obscures it
I have already tried element_to_be_clickable
but I was not able to handle it.
Can somebody help me with my problem?