I'm trying to test a website with Selenium by clicking on an element. The element is on the page but I cannot see it because it is covered with Slenium floating alert. So I cannot click on it. One of the ways to solve the problem and get access to the element is to zoom out of the page.
When I use code
browser.execute_script("document.body.style.zoom='40%'")
the page zooms out well. But the element I wanted to reach is stuck at the top of the page and not accessible for clicking anyway.
I expected to zoom out the page by pressing a combination of keys Ctrl+'-' with Selenium but failed to get any result. I tried this code
import timefrom selenium import webdriverfrom selenium.webdriver import Keysfrom selenium.webdriver.common.action_chains import ActionChainsfrom selenium.webdriver.common.by import Bywith webdriver.Chrome() as browser: browser.get('https://some_address/index.html') time.sleep(1) element=browser.find_element(By.ID, 'some_text') actions=ActionChains(browser) actions.key_down(Keys.CONTROL,element) \ .key_down(Keys.SUBTRACT,element).key_up(Keys.SUBTRACT,element) \ .key_down(Keys.SUBTRACT,element).key_up(Keys.SUBTRACT,element) \ .key_up(Keys.CONTROL,element).perform()
but zoom out does not work.