Good evening learning automation. For these lessons Python bindings documentation for selenium
6.1. Test case
import page throws an error:
ImportError: No module named 'page'
Help please solve the problem?
Good evening learning automation. For these lessons Python bindings documentation for selenium
6.1. Test case
import page throws an error:
ImportError: No module named 'page'
Help please solve the problem?
The documentation, the link to which you provided, in the next paragraph indicates that you need to create page.py file
6.2. Page object classes
An object for each web page. The following is a technique that has been created.
The page.py will look like this:
from element import BasePageElement from locators import MainPageLocators class SearchTextElement(BasePageElement): """This class gets the search text from the specified locator""" #The locator for search box where search string is entered locator = 'q' class BasePage(object): """Base class to initialize the base page that will be called from all pages""" def __init__(self, driver): self.driver = driver class MainPage(BasePage): """Home page action methods come here. Ie Python.org""" #Declares a variable that will contain the retrieved text search_text_element = SearchTextElement() def is_title_matches(self): """Verifies that the hardcoded text "Python" appears in page title""" return "Python" in self.driver.title def click_go_button(self): """Triggers the search""" element = self.driver.find_element(*MainPageLocators.GO_BUTTON) element.click() class SearchResultsPage(BasePage): """Search results page action methods come here""" def is_results_found(self): # Probably should search for this text in the specific page # element, but as for now it works fine return "No results found." not in self.driver.page_source Source: https://ru.stackoverflow.com/questions/611720/
All Articles