I have this test on selenium Python:
import pytest
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from pages.main_page import MainPage
def test_click_account(main_page):
main_page.click_account()
“main_page.click_account()” is executing this def from my main_page:
import time
from selenium.webdriver.common.by import By
from .base_page import BasePage
class MainPage(BasePage):
def click_account(self):
ACCOUNT_LINK = (By.XPATH, "//li[3]/a/span")
self.assert_boton_visible()
self.click(ACCOUNT_LINK)
“self.assert_boton_visible()” is executing this code from my main_page:
import time
from selenium.webdriver.support.ui import WebDriverWait, Select
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import ActionChains
class BasePage:
def assert_boton_visible(self):
element = self.find_element("xpath", "//li[3]/a/span")
assert element.is_displayed()
When executing the test, I receive this error: AttributeError: ‘MainPage’ object has no attribute ‘find_element’
What Im doing wrong? Im triying to do an assert checking if the element with that xpath is displayed or not