fix and add som usecases
This commit is contained in:
@@ -11,24 +11,23 @@ class BasePage:
|
||||
improve test maintenance.
|
||||
"""
|
||||
|
||||
def __init__(self, driver: WebDriver, base_url: str = "http://120.53.89.168:90"):
|
||||
def __init__(self, driver: WebDriver):
|
||||
"""
|
||||
Initializes the BasePage with a WebDriver instance and a base URL.
|
||||
Initializes the BasePage with a WebDriver instance.
|
||||
|
||||
:param driver: The WebDriver instance to interact with the browser.
|
||||
:param base_url: The base URL of the web application under test.
|
||||
"""
|
||||
self.driver = driver
|
||||
self.base_url = base_url
|
||||
self.wait = WebDriverWait(driver, 10) # Default explicit wait of 10 seconds
|
||||
|
||||
def open_url(self, path: str):
|
||||
def open(self, base_url: str, path: str):
|
||||
"""
|
||||
Navigates to a specific path relative to the base URL.
|
||||
|
||||
:param base_url: The base URL of the web application.
|
||||
:param path: The relative path to open (e.g., "/form-elements").
|
||||
"""
|
||||
url = self.base_url + path
|
||||
url = base_url.rstrip('/') + path
|
||||
self.driver.get(url)
|
||||
|
||||
def find_element(self, locator: tuple) -> WebElement:
|
||||
@@ -177,3 +176,12 @@ class BasePage:
|
||||
:return: True if the text is present, False otherwise.
|
||||
"""
|
||||
return self.wait.until(EC.text_to_be_present_in_element(locator, text))
|
||||
|
||||
def wait_for_url_contains(self, url_substring: str):
|
||||
"""
|
||||
Waits until the current URL contains the given substring.
|
||||
|
||||
:param url_substring: The substring to look for in the URL.
|
||||
:return: True if the URL contains the substring, False otherwise.
|
||||
"""
|
||||
return self.wait.until(EC.url_contains(url_substring))
|
||||
|
||||
Reference in New Issue
Block a user