driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
Scroll to bring it to the screen
driver.set_window_size(xxxx,yyyy)
First change the screen size with. I set the screen size to 1980 and 1280 because it is troublesome to scroll every time. It seems that you can scroll to other elements such as ID.
options.add_argument(f'user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36')
Impersonate a user agent.
elements = driver.find_element_by_xpath("XPATH")
loc = elements.location
x, y = loc['x'], loc['y']
actions = ActionChains(driver)
actions.move_by_offset(x, y)
actions.click()
actions.perform()
Click on the XPATH coordinates.
text = driver.find_element_by_id("ID").get_attribute("textContent")
Get with get_attribute.
It's been a month since I started, so there may be some rumors that this is different, but I would appreciate it if you kindly say it.
Recommended Posts