How to interact with a link in a grid using Selenium RC?

Using Selenium RC, I have developed all scripts in Java with JUnit test cases.

I am trying to click on a grid column that contains an "Edit" link. Below is the snippet of my code:

selenium.click("//table[@id='ctl00_POMSContentPlaceHolder_gvBillingCompany']//tr["+gRow+"]//td["+gCol+"]");

The variables gRow and gCol are integers whose values change when moving to the next row/column.

Please advise if any modifications are required for this code.

Answer №1

Here are a few tips:

  • Make sure to click on the link (<a>) instead of the cell.
  • Remember, children selectors require a single slash: //parent/child.
  • Don't forget to include tbody - it is automatically added by browsers:
    //table/tbody/tr[2]/td[3]/a[1]
  • You might have more success with a css selector:
    css=table tr:nth-child(2) td:nth-child(3) a

Answer №2

Consider the following suggestions:

selenium.click("xpath=id('ctl00_POMSContentPlaceHolder_gvBillingCompany')/descendant::tr[" +gRow+ "]/descendant::td["+gCol+"]");

This information can be found at https://www.w3.org/TR/xpath#path-abbrev

When using XPath, remember that // represents /descendant-or-self::node()/. However, //para[1] does not have the same meaning as /descendant::para[1]. The latter selects the first descendant para element, while the former selects all descendant para elements that are the first para children of their parents.

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

TypeError thrown by Basic TypeScript Class

I'm encountering an issue where TypeScript is throwing a TypeError when trying to use the class Literal from file Classes.tsx in file App.tsx, even though they are in the same file. Strangely, everything works fine on typescriptlang.org/play. // Class ...

retrieve all entries from a paginated grid

Currently, I am utilizing the datatable feature in bootstrap4 with a table that has pagination set to display 10 items per page. I have implemented a function to retrieve values from the table, however I am facing an issue where I am only able to retriev ...

Guide to transferring information from a Complex Form in nodejs and express to MongoDB

I am a newcomer to node.js and express. Currently, I am working on creating a Business Card Generator application using nodejs, express, and MongoDB. I have set up a multi-step form in ejs and now I am looking for guidance on how to store the input data ...

Creating interactive images with text overlays using HTML5 and JavaScript Canvas on user click

Hello StackOverflow community! I'm a newcomer to JavaScript programming and currently facing some challenges with the HTML5/JavaScript Canvas Combo. I have a button that, when clicked, is supposed to verify certain lines and then display an image (pr ...

Is it possible to utilize the return value from an asynchronous function within useEffect as the default value for useState

Check out this simple example I've put together https://codesandbox.io/s/4zq852m7j0. In the example, I am fetching data from a remote source and attempting to use the returned value as the input for my textfield. const useFetch = () => { const ...

Instructions for accessing and printing text from a nested ul tag with Selenium in Java

Hello everyone, I am currently learning about Selenium Automation and have created a website as shown below. Here is the HTML code: <!DOCTYPE html> <html> <head><title>Shop</title></head> <body> <ul> < ...

Using Django templates to include JavaScript files stored in the static directory

I'm facing an issue: within addWorkout.html: {% extends "workout/base.html" %} {% block footer %} <script type="text/javascript" src="{% static js/addWorkout.js %}"></script> {% endblock %} within base.html: {% load static %} <!DOCT ...

Converting SHA-256 from Java to JavaScript in an Ionic project using NPM: A step-by-step guide

In Java, I have a code snippet that needs to be converted into JavaScript using the Ionic Framework. I attempted to use Ionic App along with NPM packages like "crypto-js" and "js-sha256", but I was unable to find a suitable solution. String generate ...

Utilizing a file from external sources in WebPack 1.x beyond the webpack root directory

In my project structure, I have the following setup: Root Project1 package.json webpack.config Project2 package.json webpack.config Common file1.js I need to use file1.js in each project. The webpack v ...

Get the whole webpage content (HTML, images, JS) using Selenium with Python

Is there a way to fully download the source code of a dynamically generated website like www.humkinar.pk in simple HTML form? I've attempted using the driver.page_source function from selenium, but it doesn't seem to capture everything, leaving o ...

Adjust the height of a responsive div to match its adjacent element

Two of my divs are set to specific widths using percentages. I'm looking for a way to make the right div match the height of the left div, which changes based on the dimensions of an image and the browser window size. Is there a method to achieve this ...

Adding an item to a JSON array in Angular

I'm having trouble adding a new item to the roleList JSON array. I've tried using push/concat, but it doesn't seem to update the roleList array. Any suggestions on how to resolve this? // The javascript : function RoleListCtrl($scope) { ...

The JavascriptExecutor in Selenium WebDriver using C# consistently returns null objects

I'm having trouble accessing HTML elements using jQuery with JavaScriptExecutor and consistently encountering null reference exceptions. Any idea what could be causing this issue? Below is the code snippet I'm working with: List<Object> ...

Setting a background image as a variable in Vue.js

I am currently working on a vue.js component that includes a div.icon: Vue.component('obj', { props: ['img', 'name'], template: '<div><div class="icon"></div> {{ name }}</div>' }) While ...

Benefits and Drawbacks of Utilizing Multiple Drivers for Capybara Testing

I am currently running a series of capybara tests using Poltergeist/PhantomJS as my default driver. Some of these tests involve video and audio tags, which PhantomJS does not support. Upon setting the driver to Selenium for these particular tests, I foun ...

URL JSON data will not display markers

I am currently working on a map that fetches data from the police.uk API by allowing users to drag and drop a dot on the map to display crimes within a 1-mile radius. However, I'm facing an issue when trying to implement geocoding functionality by tak ...

Include previous input as a "phantom" thumbnail to the slider element of type "range"

https://i.stack.imgur.com/JnuCN.png Using a tutorial from w3schools, I have customized a regular range slider. The objective is to send a new value command to an external MQTT-based home automation system and display the previous value as a ghost-thumb in ...

What is the best way to fetch JSON data in React from the start and then manipulate it as needed before exporting to another file within my application?

I have a scenario where I need to fetch data from a MongoDB database using async/await fetch() and save it in a file called data.js. However, I am facing an issue with React executing "in parallel" due to the nature of async/await. This makes it difficult ...

What exactly is the purpose of the QueryString function and how does it work

I recently took on the role of editor for a website that I did not create. One of the webpages contains a map feature, and I've been tasked with changing how the map loads initially on the webpage. As I review the JavaScript code, I'm unsure if ...

javascript console to automate clicking and pressing keys

I'm in need of assistance. I'm looking to create a script that simulates pressing the Enter button 2000 times in a console and auto clicks 2000 times with no delays. I also need a key to stop this action. Can anyone help me out? Thanks in advance ...