I am encountering an issue with opening a dropdown select option upon clicking in C# while using Selenium

I am encountering an issue while attempting to open the Register page from my account. The UI developer utilized Bootstrap code, and Bootstrap developers have included a JS function on click. However, when I execute this code, an error is thrown: "OpenQA.Selenium.ElementClickInterceptedException has been thrown

element click intercepted: Element ... is not clickable at point (984, 50). Another element would receive the click: ... (Session info: chrome=77.0.3865.120)"

Attached are the screenshot links:

This is my code:

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;

namespace XTSeleniumtest
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            IWebDriver driver = new ChromeDriver();

            driver.Navigate().GoToUrl("http://freshpicksdev.isrv.tech/");

            driver.FindElement(By.CssSelector("div.modal-header .close")).Click();
            driver.FindElement(By.XPath("//a[@id='navbarDropdown']/u")).Click();


        }
    }
}
**`

> strong text

`**

Answer №1

Patience is key when waiting for the element to become visible.

driver.FindElement(By.XPath("//a[@id='navbarDropdown']/u"));

If the problem persists, provide the DOM structure of your webpage as it could be linked to interacting with the wrong element.

Answer №2

Check out the code snippet below which requires adding a reference for "SeleniumExtras.WaitHelpers" from nuget

 public class AutomationScript
    {
        public static void Main(string[] args)
        {
            IWebDriver driver = new ChromeDriver();
            driver.Navigate().GoToUrl("http://freshpicksdev.isrv.tech/");
            driver.FindElement(By.CssSelector("div.modal-header .close")).Click();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            wait.IgnoreExceptionTypes(typeof(NoSuchElementException));
            wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath("//u[contains(text(),'My Account')]")));
            driver.FindElement(By.XPath("//u[contains(text(),'My Account')]")).Click();
            driver.FindElement(By.XPath("//a[text()='Register']")).Click();
        }
    }

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

Transmitting keystrokes to components

I attempted to run the code snippet provided on this page When inspecting the Google search box in Firefox using Firebug, I found the following id: <input id="gs_htif0" class="gsfi" disabled="" autocomplete="off" aria-hidden="true" style="border: medi ...

Separation between dropdown menu subcategories

I have searched through various discussions but haven't found a solution that addresses my specific issue, especially at a beginner level. I would really appreciate some guidance. The problem I'm facing involves my drop-down menu displaying gaps ...

Enhancing browsermob precision with HAR files

I am currently utilizing browsermob in conjunction with selenium to generate a har file and then attempting to analyze the contents of that file. While examining the file, I have noticed timing information such as: 'startedDateTime': '2016-0 ...

Library written in JavaScript for extracting CSS that is relevant

Is there a JavaScript tool available that can extract the style information from HTML code? For instance, when given the following HTML snippet, it would output a style block containing all the computed styles applied to each of those elements? Input... ...

Any ideas on how to successfully implement this CSS text-decoration override?

There are moments when I question my sanity, and today seems to be one of them. Despite what I thought was a straightforward CSS code, it's just not functioning properly. What could I possibly be overlooking? Here is the CSS snippet in question: ul ...

Ensuring a full height div using CSS

I have encountered an issue and created a fiddle to help illustrate it: http://jsfiddle.net/XJpGT/ The challenge I am facing is ensuring that the height of the green box always remains at 100%, while also making sure that the green and orange boxes do not ...

Achieving a scrolling body with a fixed header in a Vue b-table

Currently, I have implemented a b-table element on a webpage to display data from a database. The table is paginated, but feedback suggests that users prefer all information displayed in a single scrolling view. However, the issue arises when I attempt to ...

Break apart animation similar to the 🎊 emoji using CSS styling

I am attempting to create an animation of a circle splitting open on two sides, similar to the ...

When the browser window is resized, the footer starts to cover the content

To prevent the divs from overlapping when the browser window is resized vertically, take a look at the code snippet below: <html> <body> <style> #box { display: flex; flex-direction ...

Discovering components using various qualities involves pinpointing specific characteristics within HTML elements

While attempting to locate an element from the HTML using an identifier that has numbers at the end, I encountered a situation where the element changes during the script execution and cannot be found. Can anyone recommend the most effective approach for ...

Setting up multiple instances of a page object and log4j in Selenium

I currently have 2 tests written within a single page factory class that consists of 3 pages classes. My question pertains to the initialization of multiple page objects and Log4j (for each test case). Is it possible to initialize these globally for all ...

Extract all potential outcomes from a search field that has a restriction on search results

Looking to extract all the names from a specific website using Python: Encountering an issue where it only fetches the top 50 results for each search. Experimented with wildcard searches in the last name field to narrow down subsequent searches, but this ...

Prevent overlapping of range sliders in HTML and CSS

I have designed a range slider with two buttons, but they are overlapping each other. I want to ensure that they do not cross over one another - where the value of the first button should be equal to the minimum value of the second button, and the maximum ...

Issues with jQuery causing responsive CSS triangles to fail implementations

Recently, I stumbled upon the interesting concept of CSS triangles created using element borders. I decided to incorporate this design into one of my custom Wordpress themes, but I encountered a problem. I wanted to add a triangle at the bottom of a div, l ...

Text that is selected within a contenteditable div: Find the beginning and end points of the highlighted text

<div contenteditable="true">This text is <b>Bold</b> not <i>Italic</i> right?</div> For instance, if the text appears in a bold format, but not italic and the user selects it, how can I determine the exact position ...

Having trouble configuring maven dependencies for RemoteWebDriver

I'm currently facing challenges resolving RemoteWebDriver in Eclipse due to Maven dependency issues. I require RemoteWebDriver to obtain the browser version for reporting purposes. Despite specifying the necessary Maven dependencies, I am still unable ...

Attempt to locate an element using Selenium in Python and continually refresh the page until the element is found

My current script locates and clicks on an element, but there are instances when the element is not present due to the item not being released yet. I would like the script to verify if the item is available and if so, click on it. If not, the page should b ...

The content div in CSS is causing the menu div to be displaced

I have encountered a difficulty in describing the issue at hand as I am still in the learning phase and consider myself a beginner. Within my container div, there are two other divs - one for the menu and another for the content. Both of these divs float ...

Issues with audio and video playback intermittently occurring on Sencha Touch 2

As a beginner with Sencha Touch 2, I am currently working on uploading images onto an iPad using Xcode. My app has audio playing on the home screen, and I want the video to start playing and the audio to stop when a specific tab is selected. However, the ...

Is there a way to prevent the imported JQuery from causing issues with current code implementations?

Being a novice developer in Html/Javascript/CSS/Jquery coding, I recently encountered an issue while integrating Jquery into my project. When I imported Jquery, the styling of simple buttons went haywire. Jquery worked perfectly fine when using its classes ...