1

I am using Unittest + Pytest. I need perfrom move over. Here is first page:

from selenium import webdriver from selenium.webdriver.common.by import By import pytest import unittest from page.home.main_page import MainPage from selenium.webdriver import ActionChains

class MainPageTests(unittest.TestCase): def setUp(self): baseURL = "https://grin.co/" driver = webdriver.Chrome() driver.maximize_window() driver.implicitly_wait(3) driver.get(baseURL) self.mb = MainPage(driver) self.driver = driver

@pytest.mark.run(order=1)

def testtitle(self):
    self.mb.creatormenu()

Here is second:

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

import time

class MainPage(): def init(self,driver): self.driver = driver

def creatormenu(self):
    time.sleep(2)
    element = self.driver.find_element(By.ID, "menu-item-17096")

    actions = ActionChains(self)
    actions.move_to_element(element).perform()
    print("Mouse Hovered on element")

And I gets error:

         device.actions = []
  self.driver.execute(Command.W3C_ACTIONS, enc)

E AttributeError: 'MainPage' object has no attribute 'execute'

venv/lib/python3.8/site-packages/selenium/webdriver/common/actions/action_builder.py:88: AttributeError ======================================================================================= short test summary info ======================================================================================== FAILED Tests/home/mane_page_test.py::MainPageTests::testtitle - AttributeError: 'MainPage' object has no attribute 'execute'

What did I miss?

Thank you in advance

1
  • actually...found myself: actions = ActionChains(self.driver) Commented May 25, 2022 at 18:31

1 Answer 1

0

Thank you for posting your answer Oleg! I had the same issue when tried to use the following functions without ".driver":

def switchToNewWindow(self):
    remote = Remote(self.driver)
    remote.switch_to.window(remote.window_handles[1])

and

def moveSlideBar(self, Xamount, Yamount, locator):
    move = ActionChains(self.driver)
    move.click_and_hold(locator).move_by_offset(Xamount, Yamount).release().perform()
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.