Home > Software engineering >  User will get the dialog when the user first time login to the portal. and i want to check terms & c
User will get the dialog when the user first time login to the portal. and i want to check terms & c

Time:01-06

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[@]//*[@]').click()
        driver.find_element(By.XPATH, Locators.continueButton).click()
    driver.implicitly_wait(10)

I am getting NoSuchElementException

This is the portal URL

Email: [email protected]
Pass: Test@2020

CodePudding user response:

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[@]//*[@]')
    if checkboxes:
        checkboxes[0].click()
        driver.find_element(By.XPATH, Locators.continueButton).click()

  •  Tags:  
  • Related