What is the best approach to locate a specific grid element to input data using Selenium and C#?

I've experimented with 'Inspect Element', Firebug, FirePath, Selenium IDE, Katalon Recorder to locate an element. However, the Css/xPath I use in my code doesn't seem to work for automating the addition of a new row scenario. In this particular case, the initial element in the grid is a dropdown, and upon selecting a value from it, a second dropdown is populated. The Css/xPath for the first element while examining the required value is:

Css:

body > div.k-animation-container > div > div.k-list-scroller > ul > li:nth-child(35)

xPath:

.//*[@id='ng-app']/body/div[4]/div/ul/li[35]

Check out the sample html code here, where I need to choose a value from the drop-down.

How can I resolve this issue so that the code consistently selects the value from the drop-down?

Answer №1

To target the element with the text "AEP Public Service of Oklahoma", you can use this XPath example:

.//div[@id='ng-app']/body/div[4]/div/ul/li[contains(.,'AEP Public Service of Oklahoma')]

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

displaying dropdown menu from bootstrap 4 on top of a div located below

Struggling to make the bootstrap 4 responsive top nav appear over my container div, but can't find a solution. This is how the Top nav should function: W3Schools editor Here is my code on jsfiddle: jsfiddle function myFunction() { var x = ...

The luminosity of the image displayed on the iPhone 13 Pro's screen

I am attempting to capture an image from a phone camera and display it on a canvas for later use. I have encountered an issue with the brightness of the image on the canvas when using an iPhone 13 Pro. The image appears brighter than expected, but this pr ...

Issue encountered when converting Jquery val() split() function to Vanilla JavaScript

As I work on transitioning my code from Jquery to Vanilla JS, there is a particular code snippet that is proving difficult to convert: function updateTextBox(nehemyah) { var delfino = $("#campotxt").val().split("\n"); delfino.remove(nehemyah); $ ...

Why do confirm or alert boxes in Safari on Windows require a double click?

I'm currently working on a simple JavaScript example where I want to display an alert box when an HTML button is clicked in SAFARI. However, I've noticed that it requires a double click to make the alert disappear from the screen. Does anyone ha ...

What causes the significant difference in website speed between Internet Explorer and Firefox?

While operating an asp.net website, I have noticed that one specific page is running significantly slower in Internet Explorer compared to other pages. Interestingly, this same page performs well in Firefox. Does anyone have insight into why this discrep ...

Guide on creating a perfectly-aligned line within a rectangular shape using CSS

I'm still learning the ropes when it comes to styling. In my web app (created with GWT), I am displaying a grid of results. In one column, I want to showcase a score visualization. The idea is to have a central black line and either a green rectangle ...

Using Android to Load HTML Content from a Database and Display in a WebView

I am currently facing an issue with loading HTML content from my sqlite database into a webview successfully. The HTML renders beautifully, however, the local file included in the HTML is not being loaded. I have placed it in the assets folder under this s ...

Attempting to create a hexagon using 127 divisions results in a gap

I am faced with a challenge of arranging 127 divs to form a hexagon shape similar to the example below: for (i = 1; i <= 127; i++) { var div = document.createElement('div'); document.getElementsByTagName('body')[0].appendChild( ...

Retrieve the immediate div sibling that comes after

I have been struggling to create an XPath query that will accurately identify a specific element within a document structure like the one below: <AAA> <div> </div> <div> </div> <div> <div id=' ...

What is the best way to display the logged-in user's username in the Bootstrap navbar once they

I currently have a login button on my navbar that opens up a login modal. I would like to replace the login button with the username of the logged-in user in that modal. I'm relatively new to PHP and MySQLi, only been here for about a week. I would ...

Having trouble making the image appear in a relative position

I am struggling to figure out why my figcaption is not positioning correctly. My image is set to relative position. Meanwhile, my figcaption has been set to absolute positioning. This should mean that the figcaption with a bottom: 60px should be positio ...

Python: Mimicking Splinter/Selenium Functionality to Test a JavaScript-Driven Website

My automated bot interacts with a dynamic website using Splinter and Selenium. Despite its effectiveness most of the time, it occasionally encounters exceptions due to random events. Debugging these occurrences is quite challenging, especially since the we ...

Tips for maintaining the full width of an image within the viewport while also preserving a fixed aspect ratio of 16:9

After extensive research on the topic, I find the solution to implementing a parallax effect using GSscrolltrigger a bit complex. This is mainly because I need to dynamically adjust the height of the parent div based on @media CSS, while ensuring that the ...

Placing a pair of buttons side by side

Having some trouble with my design. I've got a product page with two buttons, but because one is in a form, they're stacked on top of each other (see image). https://i.sstatic.net/cS9TI.jpg How can I get these two buttons to sit next to each o ...

Determination of the input parameters

Currently, I am developing an Angular application that includes a matInput field for user input. The issue I am encountering is that when the user enters a positive or negative value in the field (e.g. +5 or -5), the final output does not reflect the inten ...

Mastering Yii2: Implementing Javascript Functions such as onchange() in a View

One of the elements in my project is a checkbox: <div class="checkbox"> <label> <?= Html::checkbox('chocolate', false) ?> Chocolate </label> </div> In addition to that, I also have a span ta ...

Find and make adjustments to the primary HTML document in your Magento online shop

Trying to enhance the top banner of my Magento website tamween.biz by adding a shadow effect PNG picture. Successfully managed this on my local server using firebug and creating a new class in the coding area with all selector properties modified in the bo ...

Enhancing Animation Speed with jQuery

I've provided the code snippet at this link: http://jsfiddle.net/LnWRL/4/: Here is the HTML: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <div id="wrap_demo"> <div id="demo"></di ...

Steps to extract a hash from a document's URL

The following code is used: jQuery(document).ready(function() { console.log($(this)); }); After running this code, the object displayed in the console is: [Document mypage.html#weather] How can I retrieve the last ID from this object? In this ...

Placing a comma following each element in soup.find_all()

After finding all 'tr' elements in the soup variable, I discovered: [<tr data-row="0"><th class="left " csk="Murray,Jamal" data-append- csv="murraja01" data-stat="player" scope="row"><a href="/players/m/murraja01.html">Jama ...