Python Forum
Selenium xpath finding gif to click - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Selenium xpath finding gif to click (/thread-11836.html)



Selenium xpath finding gif to click - fyec - Jul-27-2018

I am having trouble with clicking all buttons that are defined as animation format (.gif) in a website. I use 'xpath' in selenium to find these buttons with their ids but the script doesn't continue at this line. How can I click all these buttons by finding all gifs? My script is that:
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait


driver = webdriver.Firefox(executable_path=r'D:\geckodriver.exe')
driver.get("http://svtbilgi.dsi.gov.tr/Sorgu.aspx")
driver.find_element_by_id("ctl00_hld1_cbHavza").click()
Select(driver.find_element_by_id("ctl00_hld1_cbHavza")).select_by_visible_text("15. Kizilirmak Havzasi")
driver.find_element_by_id("ctl00_hld1_cbHavza").click()
driver.find_element_by_id("ctl00_hld1_btnListele").click()
parent_handle = driver.current_window_handle
all_urls = []
all_images = driver.find_elements_by_xpath("//div[contains(@id,'OL_Icon')]/img")
for image in all_images :
     image.click()
     for handle in driver.window_handles :
          if handle != parent_handle:
              driver.switch_to_window(handle)
              WebDriverWait(driver, 15).until(lambda d: d.execute_script('return document.readyState') == 'complete')
              all_urls.append(driver.current_url)
              driver.close()
              driver.switchTo.window(parent_handle)



RE: Selenium xpath finding gif to click - snippsat - Jul-27-2018

Hmm what a terribly design and look that site has Sick
Did a quick test.
Look like all those green dot interfere when selenium shall click on one.
Did not test anymore,can search for ElementClickInterceptedException to see if someone has a solution.