Reputation: 124
When I hover over element it show table in HTML code but when I scroll, ad try again to hover, it does't work ? any help
from selenium import webdriver
import time
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(0)
url = 'https://public.tableau.com/views/IRENA_Decentralised_RE_Data_Review_2019/ExploreData?:showVizHome=no'
driver.get(url)
time.sleep(3)
for i in range(10000):
element = driver.find_element_by_xpath("//div[@class='tab-tvScrollY tvimages'][./div[@class='tvimagesContainer' and @style]]")
driver.execute_script('arguments[0].scrollTop = (0,{})'.format(str(i*49)),element)
actions = ActionChains(driver)
actions.move_by_offset(1330,200).perform()
time.sleep(3)
Upvotes: 3
Views: 372
Reputation: 4059
After spent three hours, I finally got it!
It's some Tableau behavior that hover
doesn't work as well, can't say why.
Below it's my code explaining what I did to hover all lines.
import time
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome(executable_path='./chromedriver')
driver.maximize_window()
driver.implicitly_wait(0)
url = 'https://public.tableau.com/views/IRENA_Decentralised_RE_Data_Review_2019/ExploreData?:showVizHome=no'
driver.get(url)
time.sleep(2)
scroll = driver.find_element_by_xpath("//div[@class='tab-tvScrollY tvimages']"
"[./div[@class='tvimagesContainer' and @style]]")
column = driver.find_elements_by_xpath("//canvas[@class='tabCanvas tab-widget']")[1]
action = ActionChains(driver)
for i in range(10000):
driver.execute_script('arguments[0].scrollTop = (0,%s)' % str(i * 49), scroll)
# Move cursor to hover element
action.move_to_element_with_offset(column, 0, 0).perform()
# Select HTML table
table = driver.find_element_by_xpath("//div[@class='tab-tooltip tab-widget "
"tab-tooltipBL tab-allowMouseEventPassthrough']")
# Your selenium code to extract HTML content [...]
# Move cursor to reset tableau hover function behavior
action.move_to_element(scroll).perform()
Hope it helps!
Upvotes: 1