Closed vkolgi closed 1 year ago
LOGAF Level 3 - /home/runner/work/puppet/puppet/e2e_tests/utils.py
wait_for_element
function could be improved by adding a custom exception message in the TimeoutException
block. This will make debugging easier when an element is not found within the specified timeout.Example:
except TimeoutException:
raise TimeoutException(f'Element with selector {by_selector} and value {selector_value} not found within {timeout} seconds')
find_and_click
function assumes that the element is always found. Consider adding a check to ensure that the element is not None
before calling the click
method. This will prevent AttributeError
exceptions from being raised when the element is not found.Example:
if element is not None:
element.click()
else:
raise Exception(f'Element with selector {by_selector} and value {selector_value} not found')
LOGAF Level 2 - /home/runner/work/puppet/puppet/e2e_tests/test_sauce_labs.py
Consider using a configuration file or environment variables for storing sensitive data such as SAUCE_USERNAME
, SAUCE_ACCESS_KEY
, TEST_UUID
, BUILD_STAGE
. This will make your code more secure and flexible.
The create_android_driver
function is quite long and does a lot of things. Consider breaking it down into smaller, more manageable functions. This will make your code more readable and maintainable.
Avoid using magic strings such as "http://127.0.0.1:4723"
and "https://ondemand.us-west-1.saucelabs.com:443/wd/hub"
. Consider defining them as constants at the top of your file or in a separate configuration file.
The save_server_settings
and enable_accessibility_settings
functions have a lot of repeated code. Consider creating a helper function to reduce code duplication.
Example:
def find_element_and_send_keys(driver, by_selector, selector_value, keys):
element = driver.find_element(by=by_selector, value=selector_value)
element.send_keys(keys)
TestAppium
class could benefit from a setup method to avoid repeating code in each test method. Consider using the setUp
method provided by the unittest.TestCase
class.Example:
class TestAppium(unittest.TestCase):
def setUp(self):
self.driver = create_android_driver(sauce_labs=True)
self.driver.implicitly_wait(10)
def tearDown(self):
self.driver.quit()
🐛🔒🔧
Added switch command to switch to the instructed package. The launch-able activity is the main activity from category launcher. Tested the command with camera and youtube application. In case of a wrong package name or activity of the package couldn't be started, the exception is handled and service continues as is. Demo: