Extracting JavaScript OnClick button using Selenium

I'm having trouble extracting the email address from the following URL:

https://www.iolproperty.co.za/view-property.jsp?PID=2000026825
that is only visible after clicking on the "Show email address" button. However, every time I attempt to click and retrieve the email address for scraping, I encounter an error message stating "Message: element click intercepted:". I'm not sure where I'm going wrong. Any suggestions would be greatly appreciated! Thank you in advance!

contact_email = WebDriverWait(self.driver, 30).until(EC.element_to_be_clickable((By.XPATH, '//span[@id="viewagmail"]/a/@href'))).click()

Answer №1

If the DOM elements are unstable or if the page hasn't fully loaded, consider using a time sleep function. Additionally, when using XPath, it is advisable to remove any href attributes.

(By.XPATH, '//span[@id="viewagmail"]/a')

You can then retrieve the email content by using getText() or getAttribute("href") with the specified xpath.

If you encounter issues after clicking a button and trying to retrieve an email address, consider implementing a wait until function.

invisibility_of_element_located((By.XPATH,'//a[text()='Show email address']'))

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

JavaScript Indexed Array Names: Managing Arrays with Indices

I have a collection of arrays named "list0" through "list7" which have been explicitly defined. My goal is to include each of these arrays as elements in an existing array, creating a 2D array of these defined arrays. How can I reference each 'list&a ...

How about, "Enhance your website navigation with a sleek anchor

After many attempts to implement smooth scrolling on my Bootstrap project, I have tried numerous Youtube tutorials and Google search results without any success. The latest attempt I made was following this Stack Overflow post Smooth scrolling when clickin ...

Tips for verifying an alphanumeric email address

I need to create an email validation script that allows only alphanumeric characters. <script type = "text/javascript"> function checkField(email) { if (/[^0-9a-bA-B\s]/gi.test(email.value)) { alert ("Only alphanumeric characters and spaces are ...

What is the process for duplicating a set of elements within an svg file and displaying the duplicate at a specific location?

SVG <svg width="200" height="200"> <g id="group"> <rect x="10" y="10" width="50" height="20" fill="teal"></rect> <circle cx=" ...

Error: Authorization token is required

For email confirmation, I am utilizing JWT. An email is sent to the user with a URL containing the token. Here's an example of the URL received by the user: http://localhost:3000/firstlogin?acces_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI ...

Unable to resolve the issue of Duplicate keys detected with value '0'. This could potentially lead to errors during updates

Encountered a warning in Vue js stating 'Duplicate keys detected: '0'. This warning could potentially lead to an update error. To resolve this issue, I utilized the getter and setter in the computed variable and dispatched the value to Vuex ...

The function is coming back with a value of undefined

I need some assistance with a function I have below. This function is meant to download files one by one and move them to a directory called templates. At the end, it should return the length of the directory. However, it seems to be returning an undefined ...

Maintain authentication state in React using express-session

Struggling to maintain API login session in my React e-commerce app. Initially logged in successfully, but facing a challenge upon page refresh as the state resets and I appear as not logged in on the client-side. However, attempting to log in again trigge ...

Why isn't the show/hide feature in Jquery functioning properly?

I have a div that needs to be displayed after hovering over another element. These elements are not within the same div. The popup info should appear when an icon with the class .option_36_124 is hovered over. $(".option_36_124").hover(function(){ $(& ...

Getting advertisements links using scrapy and selenium

Looking to extract the ad URLs from a website I am working on: Unfortunately, the ad URLs are dynamically loaded via javascript, making it difficult for a standard crawler to grab them. Additionally, the ads change each time the page is refreshed. I came ...

Verify if the ajax request does not contain any data

Utilizing the complimentary geocoding API provided by MapQuest I'm attempting to verify the success of a request that returned no data. Entering "vdfsbvdf54vdfd" (a nonsensical string) as an address in a form field, I anticipate receiving an alert s ...

Looking to customize WebDriver's methods

Existing Setup: driver = WebDriver.Chrome.. def get_driver(): #wrapper for webdriver return driver Additionally, there are numerous instances of: get_driver().find_el... get_driver().implicitly_wait.. spread across multiple files The Challenge: I ...

utilizing vue model attributes with `${}`

I am encountering an issue with my code. Initially, :src="labels[index]" was working fine for me. However, as my codebase expanded, I needed to use ${app.labels[index]}. Simply using ${app.labels} works, but the addition of [index] causes it to b ...

Looking for assistance with selecting a dropdown using Selenium webdriver!

Attempting to choose an option from a dropdown menu, but unable to select by value. How can I select states with values like CA, FL, TX...? new SelectElement(chromedriver.FindElement(By.XPath("//select[@id='state']"))).SelectByValue("CA"); The c ...

Ideas for displaying or hiding columns, organizing rows, and keeping headers fixed in a vast data table using jQuery

My data table is massive, filled with an abundance of information. Firstly, I am looking to implement show/hide columns functionality. However, as the number of columns exceeds 10-12, the performance significantly decreases. To address this issue, I have ...

Locate Element Using Python Selenium

Having trouble locating a specific tag inside a class. Despite trying multiple methods, I have been unable to retrieve the desired value. Check out the source code here The information I am looking for is located within the "data-description". How can I ...

Incorporate a JavaScript message using C# code in the backend

I am looking for a code snippet to execute a JavaScript function called recordInserted() that displays an alert, within the add_Click method in my code-behind file. Here is the relevant section of my code: protected void add_Click(object sender, EventArgs ...

How do I adjust brightness and contrast filters on a base64 URL?

When presented with an image in base64 format like this: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABDAAwfqNRk/rjcYX+PxrV/wtWqwJSTlboMgAAAABJRU5ErkJggg== What is the most efficient method to programmatically alter a filter (such as brightness or cont ...

The window.addEventListener function is failing to work properly on mobile devices

Hey there! I am facing an issue in my JS code. I wrote this code because I want the menu to close when a visitor clicks on another div (not the menu) if it is open. The code seems to be working fine in developer tools on Chrome or Firefox, but it's no ...

Step-by-step guide on clipping a path from an image and adjusting the brightness of the remaining unclipped area

Struggling to use clip-path to create a QR code scanner effect on an image. I've tried multiple approaches but can't seem to get it right. Here's what I'm aiming for: https://i.stack.imgur.com/UFcLQ.png I want to clip a square shape f ...