0

I am writing a test for cancel a data request at the page: https://school.moodledemo.net/admin/tool/dataprivacy/mydatarequests.php

There is a pop-up when cancel a data requestenter image description here

My code to catch this:

    def cancelRequest(self):
        toggle_button = self.driver.find_element(By.ID, "action-menu-toggle-1")
        toggle_button.click()
        cancel_button = self.driver.find_element(By.ID, "actionmenuaction-1")
        cancel_button.click()
        try:
            self.driver.implicitly_wait(10)
            self.driver.find_element(By.LINK_TEXT, "Cancel request").click()
        except:
            print("nothing")

But I cannot choose the cancel request button. It always prints nothing. Can anybody help me? Thanks

1
  • Is it an alert? Please check the iframe.
    – touero
    Commented Dec 5, 2023 at 9:38

1 Answer 1

1

If this an alert pop up message, it is recommended to employ the 'alert' method for its implementation.

alert = driver.switch_to.alert

If you wish to proceed with accepting the pop-up message, kindly write this after switching to alert.

alert.accept()

Conversely, should you choose to decline the message, You can provide this

alert.dismiss()
1

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.