Using Selenium to locate and click on a hyperlink within a table by identifying it with its displayed name

In my case, I have a table that displays records of school districts. My goal is to use Selenium in order to select the delete icon positioned in the eighth td for the district located on a row with a specific name. In this scenario, the name being QA__run and it should be found in the first td

How can I achieve this task effectively?

I already attempted:

//table[@id='districts']//tr//td//a[contains[text(),'QA__run (Selected)']]

as well as

//table[@id='districts']//tr//td//a[contains[text(),"*QA__run*"]]

However, neither selector seemed to work for me.

Currently, the closest solution I found was:

//table[@id='districts']//tr//td

This selects the first td of the first tr but isn't quite specific enough for my needs

The layout of the table is as follows:

Answer №1

To retrieve the desired data, locate the td containing specific text first, then navigate back to the parent tr element and extract the 8th td within that tr.

//table//tr//td//a[text() ='QA__run']//ancestor::tr//td[8]

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

Elements within div not aligning in a single row

I am currently working on a React application where I need to align 2 links and a button in a row under a div. However, only the links are aligning in a row, not the form fields. Below is my code snippet: <div className='header'> < ...

Encountering an issue with this error message: 'Building Workspace' has hit a snag and encountered errors during the build process

When working with Eclipse Neon and Maven 3.5.0, I encounter an error every time I try to save changes made to the pom file. This issue is preventing me from moving forward in my project as I am unable to resolve it. ...

Differentiate input elements with custom styling

I'm experiencing an issue while trying to style a specific form field in Angular 7. The style doesn't seem to be applying properly. Below is my form structure: <ul> <li> <mat-form-field *ngIf="number"> <input ma ...

Unable to run Java script with Android Driver

I am currently using appium 1.1.16 along with java-client-3.3.0.jar for executing tests on an Android device. However, I encountered an error while attempting to run a javascript. Any assistance in resolving this issue would be highly appreciated. //1 ...

The issue with EJS Header and Footer not showing up on the

I am currently building a basic todo list application using EJS. However, I am encountering an issue when running it. I would like to run app.js with the header and footer in EJS, but it seems that it is not recognizing the header despite using what I beli ...

Combining several btn-group and btn-group-vertical elements within each other

I am looking to create a button grid resembling a numpad for my project. I am utilizing angular and bootstrap 5 and thought of using btn-group and btn-group-vertical for this purpose. While this setup would work for a regular button grid, I need to have t ...

Selenium Tip: Finding the Perfect Text Match Among Multiple Occurrences

I've encountered an issue with my small selenium script. The problem occurs when there are multiple occurrences of the desired text in the list, causing the script to stop. I have attempted to use a css selector (un-commented) but it is not valid. I&a ...

Creating a dynamic shift in background color

Is it possible to use jQuery to slowly change the color of diagonal lines in a background styled with CSS, while also adding a fading effect? I have created a fiddle with the necessary CSS to display a static background. You can view it here: http://jsfid ...

Looking to design a popup using CSS styles

How can I design a pop-up window using CSS for a specific div? I also want to display additional information within another div inside the popup. ...

Debugging a Python script for extracting and saving text from PDF documents

When running the code below, it searches through the main URL, clicks on the 'Council' hyperlink to extract text from the Minutes documents stored in PDFs using PyPDF2. The issue I am facing is that the code should iterate through n pages to ret ...

What is causing the discrepancy in functionality between these two HTML/CSS files with identical code?

In this codepen, you'll find the first example: Subpar Pen: https://codepen.io/anon/pen/jGpxrp Additionally, here is the code for the second example: Excellent Pen: https://codepen.io/anon/pen/QqBmWK?editors=1100 I'm puzzled why the buttons l ...

Font size determined by both the width and height of the viewport

I'll be brief and direct, so hear me out: When using VW, the font-size changes based on the viewport width. With VH, the font-size adjusts according to the viewport height. Now, I have a question: Is there a way to scale my font-size based on ...

Is it possible to use jQuery to update CSS styles in an AJAX request

Is it possible to update the CSS of divs that are injected into files but do not exist in the main HTML file? In my main HTML file, I have: <div id="container"> <div id="page"> <!placeholder> </div></div> I am having tr ...

What steps can I take to ensure my dashboard table is dynamic, updates in real-time, and automatically reflects changes made in my MySQL database

FrontEnd Code import React, { Component, useState, useEffect } from "react"; import Navbar from "../Navbar/Navbar.js"; import BarChart from "../BarChart/BarChart"; import { Chart, Tooltip, CategoryScale, LinearScale, ...

How to alter the color of an inline SVG within an <img> element

Is it possible to change the color of an SVG image, icon, or logo within an inline HTML <img> tag using style="..."? Below is a snippet of my code featuring a button with a logo that I want to change the color of: <a href="#" ...

The div extends beyond its parent due to its height

This issue is concerning. https://i.stack.imgur.com/on8t9.jpg The border of the div extends beyond the red line. I have set this for body and html: html { height: 100%; } ::-webkit-scrollbar { width: 0px; background: transparent; /* make scrol ...

Issue with a "hover" effect on a specific input[type="submit"] button

I'm having trouble getting my CSS styles to apply correctly to the input field. Can anyone help me understand why this is happening? If you'd like to take a look at the code, here are the links to the .html file and the .CSS styles. The goal is ...

Combining selected boxes through merging

Looking to create a simple webpage with the following requirements: There should be 10 rows and 3 boxes in each row. If I select 2 or more boxes or drag a box, they should merge together. For example, if my initial screen looks like this: and then I se ...

Adjust the alignment of two headers with varying sizes

Can someone provide guidance on aligning two headers of different sizes (e.g. h3 and h5) based on their bottom edges, making them appear like a cohesive group in a sentence format? The current code snippet I am working with is as follows: ...

"Safari Selenium Python: How to Ensure DOM Updates are Reflected When Navigating to a

Utilizing the safari web driver to initiate the login page of my website is successful. I can locate elements and log in successfully. However, once logged in, the homepage loads but I encounter issues when trying to locate or click on any elements within ...