I have link on web page and after click it system dialog window is open. Everything work fine when code is in one file (simple script). When I use Page Object Model and run test it is works strange. I mean sometimes element is clickable and system dialog window appears and sometimes no but test is not failed, it pass.
element from html:
<label class="file-drop_file__input__3yejR"><input accept="image/*" type="file" autocomplete="off" tabindex="-1" style="display: none;">Upload from desktop</label>
BasePage.py
class BasePage:
def __init__(self, driver):
self.driver = driver
def click_element(self, by_locator):
try:
element = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator))
self.driver.execute_script("arguments[0].click();", element)
except EX as e:
print("Exception! Can't click on the element")
Page.py
class SmartConsultation(BasePage):
upload_from_desktop_link = (By.XPATH, "//label[@class='file-drop_file__input__3yejR']")
def __init__(self, driver):
super().__init__(driver)
def click_upload_from_desktop_link(self):
self.click_element(self.upload_from_desktop_link)
step.py
@step("Click upload link")
def click_upload_from(context):
context.app.smart_consultation_page.click_upload_from_desktop_link()
I tried to set path to link in many ways but without any good result. Always works correctly when test is run as simple script in one file, but when use POM problem appears again
Many thanks for help.