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

Updating parent scope data from within a directive without relying on isolated scope bindings

What is the best method for passing data back to the parent scope in AngularJS without using isolated scopes? Imagine I have a directive called x, and I want to access its value named a. The desired syntax would be: <x a="some.obj.myA"></x> c ...

Disabling Immediate Row Checkbox in Angular Datatable Based on Column Data

Is there a way to prevent the checkbox in a row from being checked based on certain column data? In my datatable, I need to implement a condition where if firstname="Superman", then the checkbox for that particular row should be disabled to preve ...

If the value of the input matches, set the checkbox to be

I have successfully implemented functionality that allows the value of an input to be changed by clicking a checkbox. This works without any issues. Now, I am facing the challenge of automatically checking the checkbox when the page loads, but only if the ...

Is it advisable to specify data types for my JSON data in TypeScript?

For the shopping application in my project, I am utilizing a JSON structure to categorize products as either hot or branded. However, I encountered an issue when trying to define a type for the entire JSON object labeled "full". Despite my attempts, it app ...

The built-in functions of Wordpress are not able to be identified in the ajax PHP file

As a newcomer to Wordpress development, I am facing challenges with implementing ajax on my WordPress site. I am currently working on a plugin that requires the use of ajax. However, my php file (xxxecommerce.ajax.php) is not recognizing the built-in Word ...

Nightwatch failing to locate element within iFrame

I'm currently facing a challenge when trying to access an element within an iframe. Despite successfully switching to the frame, Nightwatch keeps returning "element not found" whenever I attempt to verify its presence or visibility. Below is a snippe ...

Check the contents of two lists to determine if any values from the second list are present in the

I need to compare a list of strings (list1) with the values in another list (list2). While there are solutions available for comparing lists based on sequence ordering, it is not a requirement for my case. An example list of strings could be: List<stri ...

To modify the specified variables in data, I must deconstruct the object

Hello everyone, this is my debut post. I am seeking assistance with destructuring in order to update a variable that is defined within the "data" section. Below are the code snippets I have been working on using Vue. data: () => ({ id: '' ...

An issue arises when attempting to remove or add attributes to the select box

In an attempt to change the 'disabled' and 'selected' properties, I am trying to set them to false and then apply the 'selected' and 'disabled' properties to the first option of a select box. Below is the code snippe ...

Icon for TypeScript absent from npm package listings

Recently, I created a package and uploaded it to the npm repository. The package was displayed with an icon labeled "ts" on the website. https://i.stack.imgur.com/LoY1x.png The accompanying package.json showcased the inclusion of the "ts" icon - https:// ...

Why are the variables not reflecting the changes when an event is triggered?

I'm a beginner in programming and would really appreciate some guidance. Why are my variables not updating when I click the button?? Here is the HTML code snippet: <h1>NIM</h1> <p>Welcome to a simple edition of the game NIM</p& ...

Assigning a value to a JavaScript variable using Ajax

Struggling with a problem for hours and still can't find the issue... A registration form is set up for users to create accounts. When the submit button is clicked, a validateForm function is triggered. Within this function, some JavaScript tests ar ...

Using Lodash to Substitute a Value in an Array of Objects

Looking to update the values in an array of objects, specifically the created_at field with months like 'jan', 'Feb', etc.? One way is to loop through using map as demonstrated below. However, I'm curious if there's a more co ...

jQuery Refuses to Perform Animation

I'm facing an issue with animating a specific element using jQuery while scrolling down the page. My goal is to change the background color of the element from transparent to black, but so far, my attempts have been unsuccessful. Can someone please pr ...

How to Ensure an Element Appears Above Another Despite Z-Index Troubles?

After conducting approximately 2 hours of research on this topic, I was unable to find clear answers or solutions. Hence, I have decided to address the issue here. The problem I'm facing is as follows: Due to the nature of HTML/CSS, it seems impossi ...

Streamline your processes by automating jQuery AJAX forms

I am looking to automate a click function using the code snippet below in order to directly submit form votes. Is there a method to develop a standalone script that can submit the votes without requiring a webpage refresh: <input type="submit" id="edit ...

Steps for converting JSON into a structured indexed array

My goal is to efficiently convert the data retrieved from my firebase database into a format suitable for use with a SectionList. I have successfully established a part of the data structure, but I am facing challenges in associating the data correctly. ...

Array data causes tabs to be shown incorrectly

My attempt to create tabs similar to those in this tutorial has hit a snag. While I can easily display hard coded tabs, I'm facing issues when trying to populate the tabs from a list as they end up being displayed incorrectly. Here is the code and im ...

Encountered a 'Topology is closed' error while using EJS

After creating my profile.ejs page, I encountered an error upon reloading the page. Can someone help me understand what's causing this issue? Below is all the code I've used. My setup includes Node.js and Express as the server technologies. I cam ...

Tips for passing props while clicking on a v-data-table:

I am currently facing an issue in my app while using v-data-table. I am able to pass props with an extra slot, but I want the entire row to be clickable in order to open a dialog with the prop item: <template v-slot:item.actions="{ item }"> ...