Discovering elements in selenium can be achieved through various techniques such as

I am trying to locate the element "Holiday4" within the span class="fc-title". Should I use a CSS selector or an XPath query for this task?

<tr>

    <td class="fc-day-number fc-sun fc-future hp-cal-selected" data-date="2016-02-14">14</td>
    <td class="fc-day-number fc-mon fc-future" data-date="2016-02-15">15</td>
    <td class="fc-day-number fc-tue fc-future" data-date="2016-02-16">16</td>
    <td class="fc-day-number fc-wed fc-future" data-date="2016-02-17">17</td>
    <td class="fc-day-number fc-thu fc-future" data-date="2016-02-18">18</td>
    <td class="fc-day-number fc-fri fc-future" data-date="2016-02-19">19</td>
    <td class="fc-day-number fc-sat fc-future" data-date="2016-02-20">20</td>

</tr>

<tr>

    <td class="fc-event-container">

        <a class="fc-day-grid-event fc-h-event fc-event fc-start fc-end holiday" style="color:65280" title="Holiday">

            <div class="fc-content">
                <span class="fc-title">Holiday4</span>
            </div>

        </a>

Answer №1

Using cssSelector to locate elements

.fc-content [div:contains('Holiday 4')]

If you need more insights on finding elements in Selenium using CSS, check out this resource

For further reference on CSS selectors in Selenium, visit

Answer №2

When utilizing Python:

import selenium
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://website.com')
element = driver.find_element_by_xpath('//div[@id="content"]/p[contains(text(),"Special Deal")]')

Answer №3

Here is the Xpath for finding "Holiday4":

//span[@class='fc-title'][.='Holiday4']

Answer №4

If you're looking to obtain the content of "Holiday4," simply follow these steps.

By utilizing a Css Selector:

string text = driver.FindElement(By.CssSelector("[class='fc-title']")).Text;

Alternatively, using XPath:

string text = driver.FindElement(By.Xpath("tr/td/a/div/span")).Text;

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

PHP code for sending a file alongside displaying text on the browser using the echo command using X-SendFile

I am currently utilizing the X-SendFile Apache Module to facilitate the download of large files from our server. The downloads are functioning as expected; however, I am faced with an issue regarding outputting text to the browser when a download is initia ...

Setting border radius for the first child of li dynamically using Javascript

I am currently working on creating a navigation bar that features rounded corners for the first and last children within an unordered list. My goal is to utilize the onclick javascript function to dynamically assign these rounded corners directly in JavaSc ...

Storing past entries in a local storage using JavaScript

Currently, I am developing a JavaScript program that involves 3 input boxes. The program is designed to display whatever is typed into each input box on the page. To store and re-display previous submissions, I have implemented local storage. However, I en ...

Consolidate all CSS links into a single line

Within my HTML document, I currently have the following CSS links: myPage.html <link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family ...

What is causing the failure of these "span" elements within an "a" tag in IE7?

Here is a code snippet that I am working with: HTML (version 4.0) <div class="temperatura"> <a href="/link/" class="temperatura_localita"> <span style="padding-left:12px;"> T ...

Effortlessly adjust item width in CSS Grid

I am currently utilizing CSS Grid to showcase various tags. If a tag happens to be quite large, with a width exceeding 150px, I would ideally like that specific item to expand across multiple columns as necessary. For instance, in the visual representation ...

What's the best way to group rows in an angular mat-table?

I am working on a detailed mat-table with expanded rows and trying to group the rows based on Execution Date. While looking at this Stackblitz example where the data is grouped alphabetically, I am struggling to understand where to place the group header c ...

Choosing a data-toggle in Selenium: Tips and Tricks

https://i.stack.imgur.com/CgegX.png My goal is to interact with the tabs on this page, but unfortunately I am unable to do so. Is there a way to access the data-toggle functionality using Selenium in Python? ...

Necessary CSS selector input equivalent in Reactive Forms

Is there a similar CSS method like input:required {CSS} to style all the reactive form fields in Angular that are set as required using Validators.required in their formControl? Or is there another approach to achieve this with CSS? ...

Adjacent components

I have a query regarding the utilization of Angular. I aim to align the sentences side by side. These are two distinct components that I developed. I wish for recipe-list and recipes-details to function properly, with both statements displayed alongside ...

Application that exclusively launches the web browser

Recently, I created a basic website and now I am looking to make it accessible on mobile devices. My plan is to develop an app that opens a browser without displaying the tab bar or URL bar. I want to achieve this for both Android and iOS platforms. Are t ...

Grab onto a nested section

What is the solution for targeting the h2 span element? div#content div.view-content div.view-row-item h2 span { ... doesn't seem to be doing the trick... ...

achieving outcomes beyond iframe boundaries

I currently have an IFRAME that is responsible for loading my login page. Here is the code: <iframe src="loginForm.html"></iframe> Once the form in the IFRAME is submitted, I am looking for a way to retrieve and display the results on the p ...

Unable to locate the value property of a null object

I'm currently working on creating a Shopping Cart using HTML, CSS, JavaScript, and JQuery. The idea is that when you click "Add to Cart" for the orange item, most of the HTML elements will disappear, leaving only the table displaying the Shopping Cart ...

Dynamic CSS columns with a set width on the left and right sides

Dividing my background into two parts has been a challenge. Background Image #1 Endlessly Repeating Background Image #1 Background Image #2 Endlessly Repeating Background Image #2 In CSS, creating a background with multiple elements is not as simple as i ...

Toggle the visibility of one div while hiding another by checking a checkbox

When checkbox1 is checked, I want to hide div1 and show div2. I've attempted the code below, but it didn't work as expected. <script type="text/javascript"> function valueChanged() { if ($('.checkbox1').is(":checked" ...

Creating a dynamic x-path involves defining a static middle part while allowing the surrounding sections to adapt as needed

Let's say I have an xpath - //*[@id=':5v.0B601mzFemQrgNFh3c183UFZ3RFU'] Where only the 0B601mzFemQrg part remains static and the rest is dynamic. How can we handle this condition? I would appreciate it if you could provide me with a solut ...

retrieving dynamic data from an HTML form to JavaScript

Currently, I am dynamically adding elements using JavaScript. The count is defined and increases by one. <span style="margin-left:10px;">File Type : <select name="select_type_'+count+'" > <option value="select">Select</optio ...

Changing the Color of Links in Bootstrap CSS

I'm completely new to coding and I've decided to dive into the world of Bootstrap. However, I'm facing a hurdle: I can't figure out how to customize the default Bootstrap styles with my own CSS. After researching online, here are the c ...

Guide on modifying CSS properties when hovering over the parent element

I am working with a table structure like this: <table> <tr><td class="momdad"><i class='glyphicon glyphicon-cog'></i> Hello </td><td> Mom </td></tr> <tr><td class="momdad">< ...