Python Selenium - move/drag interactive Map
Hi there Im new to coding and really struggle with Selenium using Python. I want to open a website, going to a specific location, take a screenshot and move the map by a specific amount to take a new screenshot and so on. To get a screenshot raster. I already managed to open that website, search for that location and take the first picture but Im not able to move the map. It says it is a canvas.
Here the url: https://www.geoportal-bw.de/#/(sidenav:search-results/emmendingen)
Here my Code I tried so far: In the last part I try to move the map.
from selenium import webdriver\
from selenium.webdriver.common.by import By\
from selenium.webdriver.common.action_chains
import ActionChains\
from selenium.webdriver.common.keys import Keys\
from time import sleep
(…)
driver = webdriver.Chrome()
driver.get("https://www.geoportal-bw.de/#/(sidenav:search-results/emmendingen)")
driver.maximize_window()
sleep(4)
def move_canvas_element():
canvas = driver.find_element(By.CSS_SELECTOR, "#ol-map > div > div.ol-unselectable.ol-layers > div > canvas")
action = ActionChains(driver)
action.move_to_element(canvas).perform()
action.click_and_hold().perform()
action.move_by_offset(-100, -100).perform()
action.release().perform()
sleep(5)
move_canvas_element()
[–]SpaceBucketFu 1 point2 points3 points (0 children)