Selenium automation tool experiences difficulty in clicking anchor tags

I am trying to click on an anchor tag using Selenium. This is the code I applied:

driver.findElement(By.xpath("//a[contains(@href,'/app/setup')]")).click();

However, it seems that the code is not working as expected.

<li class="ant-menu-item" role="menuitem" style="padding-left: 24px;">
<span role="img" class="anticon">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="17" viewBox="0 0 18 18">
    <path id="Icon_ionic-md-settings" >
</path>
</svg>
</span>
<span>
Setup
</span>
<a href="/app/setup">
</a>`enter code here`
</li>

Answer №1

It appears that there is an error in your xpath expression. The issue seems to be a missing closing bracket for the contains function. Here is what you currently have:

"//a[contains(@href,'/app/setup')"

The corrected version should look like this:

"//a[contains(@href,'/app/setup')]"

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

I have just developed a Java test script using Eclipse, and now I am looking to execute it on a headless Linux CentOS VM. How

Looking for guidance on running successful test scripts created using Eclipse on a Windows system in a Linux VM via SSH. Despite numerous attempts following online instructions, I have not been able to achieve success. It seems changes might be needed in t ...

Choosing the Date Picker in Selenium WebDriver: A Step-by-Step Guide

Currently delving into Selenium WebDriver with a focus on Java. My goal is to navigate through a date picker dropdown and select specific values for date, month, and year. Here is an example of the HTML tag: <dd id="date-element"> <input id="fro ...

What is the process for comparing text from a web page with text from an external file in a web driver?

I have attempted the following code: BufferedReader reader = new BufferedReader(new FileReader("file.txt")); String line; while ((line = reader.readLine()) != null) { System.out.println(line); { String text = driver.findElement(By.xpath(("//table/tbod ...

Executing loop sequentially in Python

I am currently dealing with a block of code that is intended to crawl through websites of infinite height, like Facebook. The Python selenium script I have written requests the page's javascript to scroll down in order to load more content. However, d ...

The solution to handling a null pointer exception for webdriver in selenium

I encountered a null pointer exception for the webdriver in the JUnit code snippet I wrote below. Even after printing "driver", it shows "drivernull". *package demo; import static org.junit.jupiter.api.Assertions.*; import java.util.concurrent .TimeUnit; ...

python code unable to execute selenium script

Attempted to run the following code: from selenium import webdriver browser=webdriver.Chrome() browser.get('http://www.google.com') However, it fails to execute and displays an error message: =RESTART: C:\Users\Phani\AppData&b ...

What is the best way to interact with an element in a lengthy dropdown list using Selenium?

Whenever I attempt to click on an element, like a list of countries from a dropdown menu, I face the issue where I can only successfully click on the first few countries using xpath. When trying to click on the last country in the list, it appears that t ...

Tap the JavaScript hyperlink containing the onclick event attribute

I've put in a considerable amount of effort trying to resolve an issue with a link that contains an onclick attribute, but unfortunately, I haven't been able to make any progress. Here is the HTML code for such an element: <a href="javasc ...

Is it possible to use Beautiful Soup to locate elements only partially?

During my attempt to parse content using Beautiful Soup, I encountered an issue. The specific link in question is: The information I am trying to extract from the site is at this location: https://i.stack.imgur.com/pEZHp.png Upon examining the HTML stru ...

Is there a way to create an HTML popup that automatically opens a link and an image file side by side

Can a popup code be created to automatically open both a link and an image side by side? ...

What is the best way to leave a comment on a user's Instagram post using Senium?

Currently, I am utilizing the Selenium library in Python to execute a code that emulates typical human actions on Instagram. However, this particular action seems to be unattainable, almost as if Instagram has prohibited it altogether. I am attempting to ...

Having difficulty incorporating custom JavaScript files into a testing framework

I am facing a unique challenge while integrating the Page Object design pattern into my test suite using selenium-webdriver and node.js. The first page object, pageObject/admin/login/index.js, works seamlessly. It contains selectors and methods to fill ou ...

Is the Selenium WebDriver disregarding the setTimeout command?

Has anyone experienced the issue where the selenium.setTimeout() command is being ignored when using WebDriverBackedSelenium? Any insights or solutions? ...

The Selenium webdriver successfully refocusing on the parent window after dealing with a pop-up child window

I am facing an issue while trying to switch from a pop-up window back to the parent window that was generated by a click event. Various methods were attempted, but none of them proved successful in resolving the problem. public static String verifyHierar ...

Looking for the right way to access the subway login page?

None of the methods I have attempted for logging into the Subway website with my email and password seem to be working. Here's what I've tried: email_element = driver.find_element_by_xpath("//input[@class='signInName']") I have also at ...

The erratic performance of the Click() function in Selenium

In my work on a Product automation project (Web CMS), I have encountered inconsistent behavior when using element.Click(). Our setup involves: Selenium + Nunit GUI(unit testing framework) - For running test cases locally on a specific environment Sele ...

I am encountering difficulties with searching inside elements using Python Selenium

Struggling to find elements inside another element, the expected functionality is not there. I am dealing with a table where I need to iterate and update records if a certain cell in a row is empty. I have a list of web elements to go through for iteratio ...

Capable of extracting information from static web pages, however, unable to scrape content from dynamic

Attempting to extract the upcoming game time from ESPN, specifically for a soccer match between Juventus and AC Milan at the following link: . The Python code utilized for web scraping is as follows: import requests ...

``By leveraging the capabilities of webdriver, individuals can easily retrieve the names of all child elements belonging

I am currently using WebDriver with Java and attempting to retrieve a list of all parent nodes on a webpage. My objective is to: 1st- Obtain the names of all parent elements associated with a specific element. 2nd- Compare this new list with an existing l ...

Choose the drop down selection in Selenium based on the variable that is provided as a string parameter

Context: Card stock - includes program details, stock location and country information Customer sell card screen - when selling a new card, the customer's address must be entered. Depending on the country inputted, certain fields (state/address line ...