Selenium is having trouble finding the link within the table

While writing a Selenium script, I encountered an issue with locating a link in a table on an HTML page. Using "css=table tr:nth-child(2) td:nth-child(3) a" did not work and resulted in a "[error] locator not found" message in Selenium IDE.

However, when I used "css=table tr:nth-child(2)", it successfully located the row. I am now wondering if my CSS locator was incorrect. I believed that adding "td:nth-child(3) a" should have worked to find the link within the table data, but it did not.

Edit: I am currently working with Firefox 3.0.15

Answer №1

The following HTML code is provided:

<html>
  <body>
    <table>
      <tr><td>Hello</td><td>World</td></tr>
      <tr><td>I'm</td><td><a href="http://www.example.com/">Batman</a></td></tr>
    </table>
  </body>
</html>

A locator for the link in the second column of the second row can be written as:

css=tr:nth-child(2) > td:nth-child(2) > a

Update:

Upon further investigation, it appears that the original locator should function properly, but there is a known bug in the cssQuery library used by Selenium (). The suggested workaround provided above should work temporarily until the bug is resolved. Unfortunately, considering the lack of recent updates to the cssQuery library, it is uncertain when this issue will be addressed.

Answer №2

Encountering a similar issue with Selenium IDE 2.1.0 persists.

Currently conducting tests on multiple websites to verify if a specific URL has been updated.

The targeted link is situated within a table, typically in the 25th row from the top...

<tr>
<td>
<div align="center">
<font color="#FFFFFF">
<a target="_blank" href="http://[The link for testing] ... 

I have experimented with both

assertElementPresent  //*[starts-with(@href,'The Link')]

and

assertElementPresent  //*[contains(@*,'The Link')]

Occasionally, the first method yields results while the second one does not. In most cases, neither proves successful in locating the link.

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

I successfully managed to ensure that the splash screen is only displayed upon the initial page load. However, I am now encountering an issue where it fails to load again after I close the page. Is there any possible solution

After successfully implementing a splash screen that only plays once on page load, I encountered an issue. When I close the tab and revisit the page, the splash screen no longer plays. Is there a way to fix this problem? Perhaps by setting a time limit for ...

The appearance of CSS output is noticeably distinct between iPhones and personal computers

My issue is with the development of my website. When I access it on my PC, everything looks fine. However, when I try to visit the site on my iPhone, there is a noticeable difference in the output. The space above the navigation bar appears differently whe ...

Using Selenium Python to get around the cookiebot.com uc.js

How can I programmatically click on the cookie agreement button generated by the javascript code provided by cookiebot.com? This is an example of how it may appear in HTML: <script id="Cookiebot" src="https://consent.cookiebot.com/uc.js&q ...

Incorporate an SCSS file into the Stackblitz project

Is there a way to include an scss file in the stackblitz? I attempted it, but encountered some issues. Could you take a look and advise me on what to do? I also made an attempt to add home.html This is the project: Check out the stackblitz project here! ...

How can I access the fourth div element within the initial row of a multirow div container?

My current HTML structure is causing me some confusion. I am trying to create a CSS selector for the element with the text "DESIRED ELEMENT": <div class="TopDiv"> <div class="container"> <div class="row"> ...

Tips for maintaining the nested collapsible table row within the main table row in a React MUI table

I am working on implementing a Material UI (MUI) table that includes collapsible table rows. The challenge I am facing is maintaining consistent border and background colors across all the rows, even when some are collapsed. Currently, the separate rows ar ...

Guide on creating a JQM website with a stunning image carousel

I've experimented with several image carousels for my mobile sites, but none of them are delivering the results I seek. What I'm looking for is something similar to this site: If you view the above link on a mobile device, you'll notice th ...

What is the best way to align various types of content within a div container

I'm struggling with aligning a label next to a checkbox in my HTML code using Vue.js. Here's how it looks: <div style="margin-bottom: 15px;"> <input id="newsletterRegister" type="checkbo ...

Phonegap enables iOS keyboard to dynamically adjust screen size during use

Currently, I am developing an iOS app using phonegap 3.0 and have encountered a particular issue. In my app, there is a window where users are required to enter a promo code. The problem arises when I click on the input area (see this example) and then pr ...

Align the CSS dropdown content to the right rather than the left for a cleaner layout

The information in this dropdown menu is currently aligned to the left of the icon. I would like it to be aligned to the right. Thank you! <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://use.fontawesome.com/releas ...

Error: 'tuple' does not contain a 'tag_name' attribute - encountered while attempting to choose a dropdown option in Selenium using the Page Object Model (POM)

I am currently facing an issue while attempting to choose an index from the dropdown menu using Page Object Model (POM) in Selenium. I am encountering an error and my next step is to create functions for selection based on value and visible text. Any assi ...

Unable to select dropdown option by using xpath

When I tried to click on the link 'Бренд', it didn't seem to be working. What could have caused this issue? driver.findElement(By.xpath("//div[@class='filter-title' and text()='Бренд']")).getText() -works driv ...

The .AppendChild() method does not appear to be working as expected following the completion of

Encountering a peculiar problem here. The scripts run smoothly, but the content doesn't display on screen until I "inspect element" and then close the inspector window or zoom in/out. It's not an issue with the "display" CSS property because even ...

How to place a child <div> within a parent <div> that is fixed on the page

I am currently working on creating a modal window using HTML/CSS. My goal is to have the modal window fixed in position relative to the browser window, with a white background. Inside the modal, there will be an image at the top and a div element at the bo ...

Does the Docker container called `selenium/standalone-firefox:3.4.0-chromium` come with both Firefox and Chrome drivers pre-installed?

Wondering if the Docker image selenium/standalone-firefox:3.4.0-chromium is supposed to have both Firefox and Chrome drivers? Currently using this Dockerfile to create a selenium server: FROM selenium/standalone-firefox:3.4.0-chromium USER root ENV NODE_ ...

Using Selenium in Java, you can click on an element if it exists, and if it is not found, simply move on

I am currently in the process of developing a script to test a JavaScript application on a website. While most of the code is complete, I have run into an issue. The purpose of the script is to modify a question on the website that utilizes numerous variab ...

Resolving CSS Fluid Image Problem

Even though my site background is responsive and functions well, I am encountering problems with the images. I want them to appear "fixed" in the same position as the background, regardless of resolution changes. For example, resizing the browser from 990p ...

Unable to toggle class feature

I have a trio of play buttons for a custom player setup, displayed like so: <div> <div class="gs-player"> <div id="gs1" onclick="play(309689093)" class="fa fa-3x fa-play"></div> </div> <div class="gs-player"> ...

Attempting to optimize a webpage design for compatibility with Google's mobile-friendly testing tool

After much searching on the forum, this is my first post, so I kindly ask for patience! I am dealing with a 20-year-old website that urgently needs to be optimized for mobile devices. With almost 2200 pages, manual editing is out of the question, so I nee ...

Require styling for the heading as per the specified criteria

My task is to meet the following specifications: Show text with proper formatting <h2 class="heading"> Hello dear friends </h2> Expected outcome: https://i.sstatic.net/I4Kmq.png Specifications include: HTML cannot be changed Avoid usi ...