1

I am trying to find an element with xpath but it is not working.

import string
import random

import os


from random_word import RandomWords

import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support import expected_conditions as EC


driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))

driver.get("https://yopmail.com/en/")
driver.find_element(By.NAME, 'login').send_keys('grudsimcobottest')
driver.find_element(By.NAME, 'login').submit()

try:
    elem = WebDriverWait(driver, 60).until(
    EC.presence_of_element_located((By.XPATH, '//div[text()="Confirm account deletion"]'))
    )
finally:
    a = 1
    
confirm_email = driver.find_element(By.XPATH, '//div[text()="Confirm account deletion"]')
confirm_email.click


try:
    elem = WebDriverWait(driver, 60).until(
    EC.presence_of_element_located((By.XPATH, '//a[text()="Delete"]'))
    )
finally:
    a = 1

delete_button_in_email = driver.find_element(By.XPATH, '//a[text()="Delete"]')
delete_button_in_email.click()

This is the code^

Traceback (most recent call last):
  File "C:\Users\notgr\Desktop\Everything\SC ahks\python\yopmailmakendelete.py", line 28, in <module>
    elem = WebDriverWait(driver, 60).until(
  File "C:\Users\notgr\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\support\wait.py", line 90, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 

This is the error^

the website

If you go to yopmail.com and type in grudsimcobottest you can see it live if you like. I'm not sure why the div highlighted isn't being selected and clicked, it times out when looking for it. Help much appreciated.

1 Answer 1

1
<iframe frameborder="0" width="100%" height="100%" src="" name="ifinbox" onload="onloadifinbox()" id="ifinbox" state="full"></iframe>

Your element is in an iframe switch to it prior to finding the element.

WebDriverWait(driver, 60).until(EC.frame_to_be_available_and_switch_to_it((By.NAME,"ifinbox")))
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.