python - Selenium element was not scrolled into the viewport when the element is "huge" -
i'm doing unit test selenium webdriver python. when tried test clicking element on webpage, there error: ie: 11, windows-7
elementnotvisibleexception: message: point @ driver attempting click on element not scrolled viewport.
even if tried move element vertically , horizontally in view. there still , error when click on element e.click()
. searched online , found this, , changed e.click()
webdriver.actionchains(driver).move_to_element(e).click(e).perform()
. goes through, doesn't click, seems skip line.
here code snippet:
e = elems.find_element_by_xpath("//*[@id='scheditem_10262']/div[2]") # find sub-element elems xpath self.scroll_element_into_view(e) e.click() #webdriver.actionchains(driver).move_to_element(e).click(e).perform() def scroll_element_into_view(self, element): """scroll element view""" x = element.location['x'] self.driver.execute_script('window.scrollto({0}, 0)'.format(x)) y = element.location['y'] self.driver.execute_script('window.scrollto(0, {0})'.format(y))
the problem happens when element "huge" can't fit window. there way can click on "huge" element?
i'm new this. suggestions welcome. thanks.
update: access , click following code:
e = driver.find_element_by_xpath("//*[@id='scheditem_10262']/div[2]") self.scroll_element_into_view(e) e.click()
here snapshot, it's timeline showing cases, there 2 cases in picture. "hernia" , "trans". red 1 "hernia" lasts long, it's not displayed on webpage.
i wanna click on every case 1 one see if there windows pops-up each case. when try click manully both cases, work fine. when tried click click()
"hernia" cause error, element not scrolled viewport
instead of scrollto()
, call scrollintoview()
on desired element:
driver.execute_script("arguments[0].scrollintoview(true);", element)
Comments
Post a Comment