Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/selenium_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def selenium_driver(self):
@pytest.mark.signup
def test_template_matching(self, selenium_driver: TestUIDriver):
logger.log_test_name("T92701: Create an account")
selenium_driver.get_driver.set_window_size(1000, 1200)
selenium_driver.get_driver().set_window_size(1000, 1200)
selenium_driver.navigate_to(
"https://github.com/testdevlab/Py-TestUI#image-recognition"
)
Expand All @@ -37,7 +37,7 @@ def test_template_matching(self, selenium_driver: TestUIDriver):
@pytest.mark.signup
def test_get_dimensions(self, selenium_driver: TestUIDriver):
logger.log_test_name("T92701: Create an account")
selenium_driver.get_driver.set_window_size(1000, 1100)
selenium_driver.driver.set_window_size(1000, 1100)
selenium_driver.navigate_to(
"https://github.com/testdevlab/Py-TestUI#image-recognition"
)
Expand Down
2 changes: 0 additions & 2 deletions testui/support/appium_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,6 @@ def start_selenium_driver(
logger.log_warn(
"Could not retrieve geckodriver: " + str(error)
)
if "marionette" not in desired_caps:
desired_caps["marionette"] = True

if options is None:
options = FirefoxOptions()
Expand Down
49 changes: 29 additions & 20 deletions testui/support/testui_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def execute(self, driver_command, params=None):
:param params:
:return: TestUIDriver
"""
self.get_driver.execute(driver_command, params)
self.driver.execute(driver_command, params)
return self

def remove_log_file(self, when_no_errors=True):
Expand Down Expand Up @@ -128,30 +128,30 @@ def touch_actions(self) -> TouchAction:
meant for Appium Drivers only.
:return: TouchAction
"""
return TouchAction(self.get_driver)
return TouchAction(self.driver)

def actions(self) -> ActionChains:
"""
Will return an ActionChains object for the current driver.
:return: ActionChains
"""
return ActionChains(self.get_driver)
return ActionChains(self.driver)

def open_notifications(self):
"""
Will open the notifications panel on the device. This method is meant
for Appium Drivers only
:return: TestUIDriver
"""
self.get_driver.open_notifications()
self.driver.open_notifications()
return self

def back(self):
"""
Will perform a back action on the device in browser history.
:return: TestUIDriver
"""
self.get_driver.back()
self.driver.back()
return self

def quit(self, stop_server=True):
Expand All @@ -160,7 +160,7 @@ def quit(self, stop_server=True):
:param stop_server:
:return:
"""
self.get_driver.quit()
self.driver.quit()
if self.__process is not None and stop_server:
self.__process.kill()

Expand All @@ -170,7 +170,7 @@ def navigate_to(self, url):
:param url:
:return: TestUIDriver
"""
self.get_driver.get(url)
self.driver.get(url)
logger.log(f"{self.device_name}: Navigating to: {url}")
return self

Expand All @@ -181,7 +181,7 @@ def execute_script(self, driver_command, args: None) -> dict:
:param args:
:return: dict of the result of executed script
"""
return self.get_driver.execute_script(driver_command, args)
return self.driver.execute_script(driver_command, args)

@property
def switch_to(self):
Expand All @@ -190,7 +190,7 @@ def switch_to(self):
This method is meant for Appium Drivers only.
:return:
"""
return self.get_driver.switch_to
return self.driver.switch_to

def set_network_connection(self, number):
"""
Expand All @@ -199,7 +199,7 @@ def set_network_connection(self, number):
:param number:
:return: TestUIDriver
"""
self.get_driver.set_network_connection(number)
self.driver.set_network_connection(number)
return self

@property
Expand All @@ -209,7 +209,7 @@ def network_connection(self) -> int:
Appium Drivers only.
:return:
"""
return self.get_driver.network_connection
return self.driver.network_connection

def find_image_match(
self,
Expand Down Expand Up @@ -333,7 +333,7 @@ def save_screenshot(self, image_name="") -> str:

final_path = path.join(log_dir, image_name)

self.get_driver.save_screenshot(final_path)
self.driver.save_screenshot(final_path)

logger.log_debug(
self.new_error_message(f'Screenshot saved in "{final_path}"')
Expand All @@ -351,6 +351,15 @@ def __delete_screenshot(cls, image_name):
os.remove(image_name)

@property
def driver(self) -> WebDriver:
"""
Will return the current driver.
:return: WebDriver
"""
driver = self.__appium_driver

return driver

def get_driver(self) -> WebDriver:
"""
Will return the current driver.
Expand Down Expand Up @@ -398,7 +407,7 @@ def get_clipboard_text(self) -> str:
Will return the current clipboard text.
:return: The current clipboard text.
"""
return self.get_driver.get_clipboard_text()
return self.driver.get_clipboard_text()

def set_power_capacity(self, capacity: int):
"""
Expand All @@ -407,7 +416,7 @@ def set_power_capacity(self, capacity: int):
:return: TestUIDriver
"""
try:
self.get_driver.set_power_capacity(capacity)
self.driver.set_power_capacity(capacity)
except WebDriverException as wd_exception:
exception = self.new_error_message(
"powerCapacity method is only available for emulators"
Expand All @@ -422,7 +431,7 @@ def background_app(self, seconds):
:param seconds: The seconds to background the app.
:return: TestUIDriver
"""
self.get_driver.background_app(seconds)
self.driver.background_app(seconds)
return self

def remove_app(self, app_id):
Expand All @@ -431,7 +440,7 @@ def remove_app(self, app_id):
:param app_id: The app id to remove.
:return: TestUIDriver
"""
self.get_driver.remove_app(app_id)
self.driver.remove_app(app_id)
return self

def install_app(self, app_id):
Expand All @@ -440,15 +449,15 @@ def install_app(self, app_id):
:param app_id: The app id to install.
:return: TestUIDriver
"""
self.get_driver.install_app(app_id)
self.driver.install_app(app_id)
return self

def start_recording_screen(self):
"""
Start recording the screen on current device.
:return: TestUIDriver
"""
self.get_driver.start_recording_screen()
self.driver.start_recording_screen()
return self

def stop_recording_screen(self, file_name="testui-video.mp4"):
Expand All @@ -457,7 +466,7 @@ def stop_recording_screen(self, file_name="testui-video.mp4"):
:param file_name:
:return: TestUIDriver
"""
file = self.get_driver.stop_recording_screen()
file = self.driver.stop_recording_screen()
decoded_string = base64.b64decode(file)
log_dir = self.configuration.screenshot_path
logger.log(f"Recording stopped in {os.path.join(log_dir, file_name)}")
Expand Down Expand Up @@ -535,5 +544,5 @@ def hide_keyboard(self):
This method is meant for Appium Drivers Only.
:return: TestUIDriver
"""
self.get_driver.hide_keyboard()
self.driver.hide_keyboard()
return self