Challenges faced when using Selenium with Telerik RadMenu

For the past two days, I've been struggling to find an effective method for writing integration tests for my ASP.NET website using Selenium.

The website features a Telerik RadMenu with a hierarchical structure like this:

Root Menu
- Menu 1
  - Sub Menu 1.1
  - Sub Menu 1.2
- Menu 2
  - Sub Menu 2.1
- Menu 3
  - Sub Menu 3.1
  - Sub Menu 3.2
  - Sub Menu 3.3

When a user hovers over the "Root menu", it opens a "Menu" and upon further hover, it opens a "Sub Menu". Clicking on the "Sub Menu" then triggers a Telerik dialog box.

I attempted various methods to execute two hovers and a click operation, such as:

Method 1:

Actions action = new Actions(Browser.Driver);
IWebElement we = Browser.Driver.FindElement(By.XPath("//*[@id='ctl00_ContentPlaceHolder1_RadMenu1']"));
action.MoveToElement(we).MoveToElement(we.FindElement(By.XPath("ul/li/div/ul/li[1]"))).Build().Perform();
action.MoveToElement(we.FindElement(By.XPath("ul/li/div/ul/li[1]/div/ul/li[1]"))).Click().Build().Perform();

Method 2:

var advFilter = Browser.Driver.FindElement(By.Id("ctl00_ContentPlaceHolder1_RadMenu1"));

    Actions action = new Actions(Browser.Driver);
    var advFiltersPrimary = Browser.Driver.FindElements(By.CssSelector(".rmLevel1>li"))[0];
action.MoveToElement(advFilter).MoveToElement(advFiltersPrimary).Build().Perform();
    var advFiltersSec = Browser.Driver.FindElements(By.CssSelector(".rmLevel2>li"))[0];
    action.MoveToElement(advFiltersSec).Click().Build().Perform(); 

The generated HTML structure of the RadMenu component is detailed above.

While Method 1 works sporadically and tends to fail during the execution of hovering at the "Sub Menu" level, Method 2 often selects the wrong element even when explicitly indicating the first element.

If you have any suggestions or better ways to approach this issue, your guidance would be greatly appreciated.

Answer №1

let advancedFilter = Browser.Driver.FindElement(By.Id("ctl00_ContentPlaceHolder1_RadMenu1"));
Actions action = new Actions(Browser.Driver);
let primaryAdvancedFilters = Browser.Driver.FindElements(By.CssSelector(".rmLevel1>li"))[0];    
action.MoveToElement(advancedFilter).MoveToElement(primaryAdvancedFilters).Build().Perform();
let secondaryAdvancedFilters =  Browser.Driver.FindElements(By.CssSelector(".rmLevel2:nth-of-type(2)>li"))[0];
action.MoveToElement(secondaryAdvancedFilters).Click().Build().Perform(); 

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

What is the best way to customize global styles in nextJS?

What's the best approach to override CSS rules from my global.css file for specific pages within my website? ...

Step-by-step guide on importing the Selenium library through the use of the built-in import_library()

I'm currently facing an issue while attempting to import selenium through python code. Below is the snippet of the code I am using: from robot.libraries.BuiltIn import BuiltIn builtin = BuiltIn() builtin.import_library(r'C:\project\venv ...

Blurry oval box shadows in CSS are not visually appealing

I'm working on a school project that involves replicating a website. I'm trying to achieve a shadow effect under text in an oval shape, but so far my attempts have just resulted in a blurry rectangle. Here is what I have currently: Click here A ...

How to Locate a WebElement in Java Selenium Using the Value Attribute

Is there a method to locate an element on a webpage using its value attribute? <option value="abc">Some text here</option> <option value="bcd">Some text here</option> I considered creating a list of WebElements based on the tag na ...

What's the best way to choose a particular line of text on a webpage using a webdriver - through keyboard commands or mouse controls?

Is it possible to use ChromeDriver to select a specific line of text on a web browser screen and change its style? For example, clicking the bold button in an editor toolbar. Here is an example of HTML code: <p id="boldId">bold </p> I have ...

Storing dynamically generated images into a database and linking them to an image button

Random rd = new Random(); string data = rd.Next(111111111, 999999999).ToString(); QRCodeGenerator q = new QRCodeGenerator(); QRCodeGenerator.QRCode qc = q.CreateQrCode(data, QRCodeGenerator.ECCLevel.Q); ...

rendering google charts using jade template

I am facing an issue while trying to display a google annotated chart on my jade project. I managed to successfully load a pie chart, but I am having trouble rendering a chart that requires the container element size to be explicitly defined. You can find ...

Using Jquery to dynamically adjust the size of a div based on the width and height of the browser window

How can I dynamically change the height of a .test div based on the browser width and height? I want the value to update whenever the browser is resized. $(document).ready( function() { window.onresize = function(event) { resizeDiv(); ...

The error message "Invalid column name 'False' with SqlConnection" indicates a problem with the column name in the SQL

I encountered an error Invalid column name 'False' when running the following statement reader = cmd.ExecuteReader(CommandBehavior.SingleRow); It seems like the issue stems from SQL treating boolean values as "bit" and not converting false to ...

Creating a Navigation Bar with a Dropdown Menu in HTML

Apologies if this question has been asked before, but I've searched everywhere and can't find an answer. All my searches just bring up dropdown menus with <nav></nav> Consider this table (serving as a navigation bar): <table cl ...

Python Selenium fails to fetch the alt src attribute in web scraping operations

I can't seem to access the img src for all of the products. Sometimes, the Image src attribute value returns "None" for certain elements. It appears that the image elements are missing the alt specification, causing the element to look like this: < ...

Is there a way to position text at the bottom of a card?

Looking to showcase multiple articles on a single page? I utilized Bootstrap 5 cards to create a visually appealing layout. While everything turned out as I hoped, the only issue I'm facing is that the "read more" link is not positioned at the bottom ...

Trouble with highlighting the chosen menu item

I have been attempting to implement this code snippet from JSFiddle onto my website. Although I directly copied the HTML, used the CSS inline, and placed the Javascript in an external file, the functionality does not seem to be working properly. Feel free ...

connect environment variables to nested configuration settings

In my appsettings.json file, I have the following nested data: { "Jwt": { "PublicKey": "...", "PrivateKey": "..." }, ... } The objective is to run this application in WSL/Docker/etc. Therefor ...

The excessive use of Selenium Webdriver for loops results in multiple browser windows being opened simultaneously, without allowing sufficient time for the

Is there a way to modify this code so that it doesn't open 150 browsers to google.com simultaneously? How can I make the loop wait until one browser finishes before opening another instance of google? const { Builder, By, Key, until } = require(& ...

Styling the footer of a webpage using CSS to adapt to different browser

I am currently working on a webpage that includes a footer. The footer is positioned correctly, but I encounter an issue when resizing the browser from bottom to top. For further details, please refer to the image below: Below is the CSS code for my foote ...

deleting the digits following the decimal point

When converting a string to decimal using Convert.ToDecimal() in the razor engine, I want the result to be rounded off to the nearest integer value. I have attempted to use Math.round, Math.ceil, and String Format, but so far none of them have been succes ...

Prevent spaces from being entered in a textbox in asp.net with JavaScript

How can I prevent spaces from being entered into a textbox using JavaScript? My current script works, but fails when the space bar is pressed continuously. Any suggestions on improving this issue would be greatly appreciated. Below is the code I am curren ...

Having trouble with jQuery ajax posting - receiving null value in alert box

My XML service is returning null responses, and I'm having trouble figuring out why. Any help in solving this issue would be greatly appreciated. When sending a username and password through the service, both correct and incorrect credentials are lea ...

Ways to effectively conceal an HTML div element with CSS or JavaScript

Is there a way to hide the div element that is nested inside a bootstraps radio or checkbox container using jquery? I'm unable to upload an image, but here is a preview: http://prntscr.com/6wrk2m <style> .my-radio{ border: 1px solid #F0F; } &l ...