2

I am trying to select the confirmation box using Python and Selenium. I am able to click the 'Transfer' button then I am prompted with the following message "Are you sure you want to transfer the selected account items and permissions to Backup Backup (backup)?" Then there are two buttons
1."Cancel"
2."OK"

Click transfer button to transfer account

When I get to this part, I am unable to get Selenium to go to the next step, which is clicking the "OK" button.

"OK" button to confirm account transfer

Below is the HTML.

<div style="padding-top: 15px;">
<input id="submit_transfer" class="button" name="submit_transfer" onclick="return verifyTransfer('');" value="Transfer" type="submit"/>
<input id="do_transfer" name="do_transfer" value="0" type="hidden"/>
<input id="delete_user" name="delete_user" value="0" type="hidden"/>
<input id="cancel_transfer" class="button" name="cancel_transfer" value="Cancel" type="submit"/>
</div>

def transfer_account(drive):
    """

    :param drive: 
    :return: 
    """
    transfer_account_xpath = ".//*[@id='submit_transfer']"

    test = ".//*[@id='submit_transfer']"

    transfer_account_ = drive.find_element_by_xpath(transfer_account_xpath)
    transfer_account_.click()

    al = driver.switch_to.alert()
    print al.text

    time.sleep(3)

    # result = None
    # try:
    # except UnexpectedAlertPresentException:
    #     print 'error'
3
  • You have to change something called the "frame". I haven't used selenium in a long time, but from what i recall, if you go ahead and look deeply into the html of your website, you'll probably find different 'frames". I'm not sure how to do this, but i hope this nudges you in the right direction Commented Apr 30, 2017 at 20:22
  • @AbdulrahmanAttia , that's something that I haven't tried. I'll let you know if it helps. Commented Apr 30, 2017 at 20:26
  • Look at this answer. it shows you how to do it. Answer Commented Apr 30, 2017 at 20:28

1 Answer 1

0
   try:
    WebDriverWait(drive, 3).until(EC.alert_is_present(),
                                    'Timed out waiting for PA creation ' +
                                    'confirmation popup to appear.')

    alert = drive.switch_to_alert()
    alert.accept()
    print "alert accepted"
except TimeoutException:
    print "no alert"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.