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

ASP.NET File Transfer: Uploading and Downloading Files

As a beginner in ASP, I have two questions that are related: What choices do I have for adding controls dynamically to my web part to enable users to upload files larger than 100MB to the server? What options do I have for controls that can prompt a file ...

What is the best way to place a semi-transparent black overlay on an image?

<html> <head> <style> #contain_main {background-color:black; width:100%; height:auto;} #main {width:100%; height:700px; background-image:url("https://www.sappun.co.kr/shopimages ...

Manipulate Images Efficiently with jQuery

Are there any jQuery plugins or JavaScript controls available that can display an array of images, with the option to delete an image based on user action? For example, something similar to this: , but with a dedicated delete button on each image. One ad ...

Efficient xpath query fails to function with Selenium in Python

The initial xpath query functions correctly, however the subsequent one encounters an issue: Initial set: FieldElementParent_obj = Driver.find_element(by=By.XPATH, value="//div[contains(text(), '%s')]/following-sibling::div" % FieldTit ...

Choose a single SVG file based on its unique ID

Looking for some guidance - I have a vector file with 40 svgs all combined into one image. Each vector is identified by an id inside the <g> tag. How can I select a specific svg from this single file without choosing the entire image in html? PS: E ...

The alignment of the horizontal menu items is off

Currently, I am working with asp.net and dealing with a horizontal menu issue. The alignment problem arises where the right side of Menu B appears higher than the left one (Menu A). I have included my code below for reference. Any suggestions or assistance ...

Achieving Content Centering in React Material UI: A Guide to Aligning to the Middle of the Page

Currently, the button is displaying in the top left corner. How can I move the button to the center of the page? import {Button} from '@mui/material'; function App() { return ( <Button variant="contained">Hello World</ ...

A step-by-step guide on utilizing jQuery to cyclically change the background color of elements upon clicking, and resetting the colors upon clicking another element

So I've been working on a solution to change the background color for accessibility purposes on a client's website. To achieve this, I have a set of div elements with different background colors and I'm using jQuery to update the body backgr ...

What steps are involved in designing a chic panel with additional style elements?

I am interested in developing a FancyPanel Control that can automatically apply styles to the content within it. Here is an example of what I have in mind: <asp:FancyPanel runat="server" id="pnl1"> <Header> Header Text </Heade ...

Tips for maintaining an active Chrome browser using Selenium in Python

Looking to automate opening the Google page using Python code in Visual Studio? Check out this snippet: from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager #browser = webdriver.Chrome(ChromeDriverManager().install()) Pa ...

The method WebElement.find is not able to locate the child element

I'm attempting to extract the child element (Card Number) from HTML code where all tags and class names are identical. Here's a snippet of the HTML code <li class="paymentMethods-stored"> <li class="paymentMethod&quo ...

Displaying user input data in a separate component post form submission within Angular

I recently developed an employee center app with both form and details views. After submitting the form, the data entered should be displayed in the details view. To facilitate this data transfer, I created an EmployeeService to connect the form and detail ...

Acquiring recognizable incorrect XML using Selenium automation technology

Currently, I am facing a challenge with my Selenium test that involves retrieving raw XML from a web server. The issue arises when one of the XML documents is missing a root element, making it invalid. My objective is to acquire the original source of the ...

Modify the border in jQuery if a specific div exists within a list item

Here is a collection of items: <div class="wine"> <H1>Title</H1> <div class="promotion"></div></div> <div class="wine"> <H1>Title</H1> </div></div> <div class="wine"> <H1>Title& ...

What is the best way to remove existing API requests in selenium?

There is a single button that, when clicked in older versions, sends a request to /api/accept. After upgrading, the same request is sent. However, in the latest version, the API request changes to /api/acceptconfirm. Is there a way to clear previous API r ...

Tips to position a div directly on top of table cells using absolute positioning

I have a div inside the second table cell that I want to position absolutely right outside the <td>. Currently, the issue is that the <td> elements below are overlapping the div. Eventually, each <td> will contain a div that appears on ro ...

Discover the versatile functionalities of ASP. NET CORE MVC through its CLI command interface, similar

Just wondering, does ASP NET CORE have the ability to create custom CLI commands like the Command class in PHP Symfony? https://symfony.com/doc/current/console.html In Symfony, you would first create a class that extends Symfony\Component\Conso ...

Combining BackgroundImage and Overlay in React for a Stylish Overlapping

I was looking to add a background overlay on my background image. Below is what I was trying to achieve: https://i.sstatic.net/NaZ6L.png Please take a look at my codesandbox as well Click here image: { backgroundImage: "linear-gradient(0 ...

Trouble adjusting opacity with CSS in @media queries for maximum width restrictions

When building a webpage with a collapsible header and a fading large logo that transitions to a smaller version in a different location upon scrolling down on the desktop view, there seems to be an issue. The smaller logo's opacity property does not r ...

The structure of the figure tag for HTML5 validation

Could you please confirm if the Figure tag is correctly used in the html structure? Regarding html5 validation, can I use this structure? <a href="#"> <figure> <img src="" class="img-responsive" alt=""> <figcaption> ...