简体   繁体   中英

User will get the dialog when the user first time login to the portal. and i want to check terms & condition checkbox only first time

I am working on one project. and in this project, I have created an account from the master portal. and set a password for it. when users first-time log in to the portal they will get a dialog for terms & conditions. and I want to check the checkbox only one time.

This is my login method:

@pytest.fixture()
def PracticeLogin(setup):
    driver = setup
    driver.get(loginSheet.cell(3, 2).value)
    driver.implicitly_wait(5)
    login = LoginScreen(driver)
    login.SetUsername(loginSheet.cell(3, 3).value)
    login.SetPassword(loginSheet.cell(3, 4).value)
    login.SignIn()
    if "Terms & Policies" in driver.page_source:
        driver.find_element(By.XPATH, '//div[@class="modal-dialog"]//*[@class="checkbox checkbox-success"]').click()
        driver.find_element(By.XPATH, Locators.continueButton).click()
    driver.implicitly_wait(10)

I am getting NoSuchElementException

This is the portal URL

Email: monica.compound@mailinator.com
Pass: Test@2020

Please try this:

@pytest.fixture()
def PracticeLogin(setup):
    driver = setup
    driver.get(loginSheet.cell(3, 2).value)
    driver.implicitly_wait(5)
    login = LoginScreen(driver)
    login.SetUsername(loginSheet.cell(3, 3).value)
    login.SetPassword(loginSheet.cell(3, 4).value)
    login.SignIn()
    checkboxes = driver.find_elements(By.XPATH, '//div[@class="modal-dialog"]//*[@class="checkbox checkbox-success"]')
    if checkboxes:
        checkboxes[0].click()
        driver.find_element(By.XPATH, Locators.continueButton).click()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM