0

I want to activate the account from the email. This is the mail i am using: http://www.yopmail.com/en/ its a temporary mail . I used all the methods as far as my knowledge but its even finding the element and returns the empty list. I want to click the Activate anchor tag. This is the structure:

    <p class="description center" style="font-family:Roboto, 'Arial Narrow', Arial;margin:0;text-align:center;color:#797979;line-height:24px;font-size:16px;margin-bottom:10px;margin-top:20px;margin-left:auto;margin-right:auto;">
    <a style="color:#f04877;" href="https://mandrillapp.com/track/click/31118617/devauth.eventjini.com?p=eyJzIjoiTFlnX0FQclZFN1d6bTNMUk9uNnFiVGxuX0QwIiwidiI6MSwicCI6IntcInVcIjozMTExODYxNyxcInZcIjoxLFwidXJsXCI6XCJodHRwczpcXFwvXFxcL2RldmF1dGguZXZlbnRqaW5pLmNvbVxcXC9hdXRoXFxcL2FzdVxcXC9QR09TVTcweS0yMDIwMDMwNl8wODQyNDFcIixcImlkXCI6XCJjYmE3OGM0OGY0OTM0MDc3ODZmMGQyYzY4YWE4YjU1ZVwiLFwidXJsX2lkc1wiOltcIjcwYjBiYTU0MGViMGI0ZWUwOTM2OThlYTU4NjQ2NDRlMWEwYmU4OTZcIl19In0" rel="nofollow">
        <b>Activate</b>
    </a>
</p>
<p class="description center" style="font-family:Roboto, 'Arial Narrow', Arial;margin:0;text-align:center;color:#797979;line-height:24px;font-size:16px;margin-bottom:10px;margin-top:20px;margin-left:auto;margin-right:auto;">OR</p>
<p class="description center" style="font-family:Roboto, 'Arial Narrow', Arial;margin:0;text-align:center;color:#797979;line-height:24px;font-size:16px;margin-bottom:10px;margin-top:20px;margin-left:auto;margin-right:auto;">
    Copy and paste the link below in your browser to activate your Eventjini ID.
</p>
                

Code trials:

 elements = WebDriverWait(driver, 10).until(EC.presence_of_all_elements_located((By.XPATH,"/html/body/div/div[3]/div[2]/center/div/table/tbody/tr[1]/td/table/tbody/tr/td/center/p[4]/a/b")))
 for element in elements:
     print(element.text)
     if element.text == 'Activate':
         element.click()
        

and

//b[text()='Activate']
Guy
  • 46,488
  • 10
  • 44
  • 88
karthi
  • 3
  • 3
  • @DebanjanB Please read [What are tags, and how should I use them?](https://stackoverflow.com/help/tagging), pay close attention to the first paragraph and the *Should I use tags in titles?* section. – Guy Mar 09 '20 at 05:25

2 Answers2

1

Can you try clicking using XPATH.

driver.find_element_by_xpath("//a[text() = 'Activate']").click();
Naveen
  • 770
  • 10
  • 22
0

The desired element is an Angular element so to locate the element you have to induce WebDriverWait for the element to be clickable and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "p.description.center>a[href*='eventjini']>b"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//p[@class='description center']/a[contains(@href, 'eventjini')]/b[text()='Activate']"))).click()
    
  • Note : You have to add the following imports:

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352