If an <a> element is missing its href attribute, it will be non-clickable and unable to

I'm in the process of using Python/Selenium to automate the extraction of calendar appointment information from a specific website.

When interacting with the webpage, triggering an action displays a popup containing detailed calendar appointment information:

<a class="fc-timegrid-event fc-v-event fc-event fc-event-draggable fc-event-start fc-event-end fc-event-future fc-event-future fc-event-show" tabindex="0" data-calendar-event-1856361581="" data-test-appointment-event="">

My goal is to either prompt Python to display the aforementioned popup or retrieve the information stored within

data-calendar-event-1856361581=""
.

Even if I don't open the popup, I believe it's possible to access the necessary details through one of the <a> attributes:

data-calendar-event-1856361581=""
. The value of 1856361581 contains the appointment ID essential for constructing the URL to trigger the popup. Nevertheless, I'm struggling to identify a method to extract the
data-calendar-event-1856361581=""
information. Each calendar appointment possesses its distinct appointment ID under data-calendar-event, and my task involves iterating through all appointments.

While I can locate the specified element through XPATH, employing .click fails to reveal the popup:

appt_path = 'appt_path = '//table/tbody/tr/td/div/div[2]/div[1]/a''
appt = driver.find_element(By.XPATH, appt_path)
appt.click

In an attempt to discover any reference related to

data-calendar-event-1856361581=""
, my efforts have so far yielded no results:

print(appt.get_property('attributes')[0])
print(appt.get_attribute('class'))

If anyone could offer guidance on enabling the popup display or capturing

data-calendar-event-1856361581=""
, it would be greatly appreciated. Thank you!

Answer №1

Consider this sample HTML snippet:

<a class="fc-timegrid-event fc-v-event fc-event fc-event-draggable fc-event-start fc-event-end fc-event-future fc-event-future fc-event-show" tabindex="0" data-calendar-event-1856361581="" data-test-appointment-event="">

If you want to extract the attribute named data-calendar-event-1856361581, you can achieve that using the get_attribute() method in the following manner:

print(driver.find_element(By.XPATH, '//table/tbody/tr/td/div/div[2]/div[1]/a').get_attribute("outerHTML").replace("=", " ").split(" ")[13])

Evidence of concept

The code below showcases this process:

outerHTML = '''<a class="fc-timegrid-event fc-v-event fc-event fc-event-draggable fc-event-start fc-event-end fc-event-future fc-event-future fc-event-show" tabindex="0" data-calendar-event-1856361581="" data-test-appointment-event="">'''
print(outerHTML.replace("=", " ").split(" ")[13])

Result:

data-calendar-event-1856361581

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

Safari is unable to establish a connection with the local URL: http://127.0.0.1:5000

I am attempting to execute this Flask code for a simple "hello world" application: app = Flask(__name__) @app.route("/") def hello_world(): return "<p>Hello, World!</p>" However, Safari is refusing to connect to the URL ...

Locating the origin of an import in Python

When working on a django project, you may often come across code like this: from settings import * or from local_settings import * After these imports, you might find yourself accessing settings using something like: from django.conf import settings ...

I am unable to execute this Python script

Having an issue with a syntax error while running my Python program. age = int(input('how old are you?22') Next_year_age = age + 1 print(f'on my next birthday, I will be {next_year_age}.') ...

Attempting to navigate a menu by hovering over it and selecting a link from the sub-menu, only to be met with unsuccessful results

I'm currently practicing how to hover over a menu and then click on a link in the sub-menu. For this exercise, I need to visit the URL "", hover over "Hello Sign in", and finally click on the link labeled "Start here". I've managed to successfu ...

Check for the presence of incorrect information to verify its visibility

My current task involves writing a test in Selenium where I have designated all my web elements in a page object package. To access the web element in my test, I am utilizing S.getColumn(). The getcolumn() function retrieves the web element of the column ...

Error encountered in dataflow job initiated by CloudFunction: ModuleNotFoundError

Hey there, I'm encountering an issue while trying to create a dataflow job with CloudFunctions. All my CloudFunctions settings are in place. I'm fetching a scripting package (Python) from Google Storage. Within the .zip file, I have the followi ...

Exploring sequences using a recursively defined for loop

I am having trouble writing a for loop to eliminate number sequences in combinations from a tuple. The loop seems to only check the first value before moving on to the next, and I can't figure out where to define the last value properly. It keeps comp ...

How can one maintain code execution in Selenium Python and Pytest after the initial failure occurs?

How can one ensure that code continues to execute even after the first failure in Selenium Python and Pytest? Desired Outcome: Ensure that execution does not halt after encountering a failure, and that failed test cases are still reported as failures in t ...

Using Selenium with Python to log in via a pop-up interface

Currently, I am attempting to log into a certain website using Python 3's selenium webdriver. To start the login process, I first have to click on the "Inloggen" button. Following that, I need to enter my username and password before clicking on the n ...

Converting UTF-8 values to strings using Python 3

Hello, I am currently using Python3 and I need to convert a utf8 value to a string by decoding it. Here is the code snippet I have so far: s1 = '\u54c7' print(chr(ord(s1))) # print 哇 It works fine when the input is just one character, ...

What is the method for using a Python turtle to illustrate the Collatz sequence as a line graph?

def generate_sequence(number): if number <= 0: print("Zero or negative numbers are not even, nor Odd.", "Enter number >", number) else: print(int(number)) while number != 1: #number is e ...

Utilizing Python's regular expressions for parsing and manipulating Wikipedia text

I am attempting to convert wikitext into plain text using Python regular expressions substitution. There are two specific formatting rules for wiki links: [[Name of page]] [[Name of page | Text to display]] (http://en.wikipedia.org/wiki/Wikipedia:Cheat ...

What is the best way to access the download path in browser preferences?

In my C# code, I am using Selenium to perform tests that involve file downloads. While I can successfully download files in my tests, I am facing issues with verifying the success of the downloads. As a solution, I want to retrieve the current download pat ...

Transforming values in a 2-dimensional array from strings to numerical data

Data From External Source Hello there, I've been utilizing the read_csv function in Python to pull data from a specified URL. The dataset I'm working with contains a column filled with character/string values, while the remaining columns are co ...

Exploring DFS problem-solving techniques using recursion - uncovering its inner workings!

Let's tackle this challenge We have a collection of n nonnegative integers. Our goal is to manipulate these numbers by adding or subtracting them in order to reach our target number. For instance, to achieve the number 3 using [1, 1, 1, 1, 1], we hav ...

Automate the selection of dropdown values in a Selenium script based on user input received from the console

I need help selecting a specific value from a drop-down menu after an image (Stripe.com) has been added and a user input is passed through the console. Currently, my code is only comparing zero values from the drop-down with the user input. Here is the co ...

There is no overload that matches this call in Next.js/Typescript

I encountered a type error stating that no overload matches this call. Overload 1 of 3, '(props: PolymorphicComponentProps<"web", FastOmit<Omit<AnchorHTMLAttributes, keyof InternalLinkProps> & InternalLinkProps & { ...; ...

Is there a way to confirm the alignment of dropdown selections with the user interface choices in Selenium WebDriver with Java?

I've managed to create code that reads options from a property file, but I'm unsure how to verify if the same value exists in the UI drop-down. If anyone could assist me with this code: @Test() public void Filterselection_1() throws Exception{ ...

What is the accurate Scrapy XPath for identifying <p> elements that are mistakenly nested within <h> tags?

I am currently in the process of setting up my initial Scrapy Spider, and I'm encountering some challenges with utilizing xpath to extract specific elements. My focus lies on (which is a Chinese website akin to Box Office Mojo). Extracting the Chine ...

Converting selected div classes into a structured dataframe

When using BeautifulSoup, I am attempting to extract data from the paths below: <div class="col-md-8 queryResponseBodyValue">2023-02-02</div> <div class="col-md-8 queryResponseBodyValue">2003-12-26</div> <div ...