Home > Mobile >  How move to toolbar of browser [selenium] [python]
How move to toolbar of browser [selenium] [python]

Time:12-13

Please tell me how I can move the cursor to the toolbar of browser to see a popup modal window (https://the-internet.herokuapp.com/exit_intent)

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By


class TestExitIntent:

    def setup_method(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://the-internet.herokuapp.com/exit_intent')
        self.driver.implicitly_wait(5)

    def test_exit_intent(self):
        action = ActionChains(self.driver)
        action.move_by_offset(150, 0)
        action.perform()

        self.driver.find_element(By.XPATH, "//div[@class='modal-footer']/p").click()

CodePudding user response:

Unfortunately this can not be done with Selenium / ActionChains.
There are multiple existing questions about this saying this is not possible.
In Java we can do that with external framework called Robot imported from java.awt.*
With Python this probably can be done with PyAutoIt but I'm not sure about this.

import pyautogui

pyautogui.moveTo(150, 150)
  • Related