Issue with Selenium: Unable to select the WebElement

I am a beginner with selenium and I have encountered a problem while trying to click on a specific element using the following locators. Unfortunately, none of them seem to work as expected and my scripts just skip over that particular line without any errors being shown.

Here is the HTML snippet:

<a class="board-icons" href="/htw/qmsHtwDoc/newRegQueries">
    <i class="fa fa-file-text-o"></i>
</a>
driver.findElement(By.cssSelector("i.fa.fa-file-text-o")).click();

(or)

driver.findElement(By.xpath("//div[3]/div/div/div/a/i")).click();

(or)

driver.findElement(By.xpath("//div[@id='sub-container']/div/div/div/a/i")).click();

I also tried using the Actions class, but it did not help in resolving the issue.

Actions actions = new Actions(driver);
WebElement ele = driver.findElement(By.xpath("//div[@id='sub-container']/div/div/div/a/i"));
actions.moveToElement(ele).build().perform();
ele.click();

If anyone has suggestions or can provide assistance with this issue, it would be greatly appreciated.

Answer №1

Here is a suggested XPath for your query:

//div[@id='sub-container']//a[@class='board-icons']/i[@class='fa fa-file-text-o']

I hope this solution works for you!

Feel free to reach out if you encounter any difficulties.

Answer №2

Click on the board-icons tag to see what happens. To do this in Selenium, use the following code: driver.findElement(By.cssSelector("board-icons")).click()

Answer №3

Is the visibility of that element dependent on any specific action? If so, consider using an explicit wait. Apply an explicit wait for the element to become clickable.

WebDriverWait wait = new WebDriverWait(driver, 15); wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@class='board-icons'] "))); driver.findElement(By.xpath("//a[@class='board-icons'] ")).click();

Answer №4

Give this a shot: object = driver.locateElement(By.cssSelector("a[class='board-icons']"));

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

Place the Div in a consistent position on images of varying widths

I have a dilemma with my class that is supposed to display images. The issue arises when I try to place a div within an image inside this class. Everything works smoothly when the image takes up the entire width of the class, but as soon as the image widt ...

Problem encountered when using a BufferedReader within a while loop

My script function is giving me some trouble. Let me explain - I'm trying to create a loop that gradually modifies a text document based on user input from the console. The text document has several "INSERT" entries which the user can replace with t ...

The Image Slider functions smoothly in Chrome, but encounters issues in IE11

Here is a link to the code I've been working on: http://jsfiddle.net/wf32jbhx/ I attempted to host images on my SharePoint site, but they ended up stacking on top of each other instead of formatting properly. Oddly enough, everything appears fine in ...

Personalize the option for yiiootstrap4ActiveField::radioList in Yii2

I am currently using yii\bootstrap4\ActiveField::radioList and I am attempting to include HTML tags inside the options of my radioList. $list = [ 0 => '<strong>Option1</strong><br> lorem ipsum lorem ipsum&ap ...

When trying to retrieve the Unix time in milliseconds using the MongoDB Timestamp Output Format, it returns an object labeled "$numberLong" instead

I am currently working on a Spring Application that stores JSON data in MongoDb. Users can search for specific data by entering a time interval start and end. To enable the use of regex (lte and gte) for filtering data from the database, I store the Time a ...

Tips for integrating the Brave browser with Selenium on Catalina

I came across this example for using the brave browser on Windows. I'm wondering if it would also work on Catalina just by updating the driver_path and brave_path? Additionally, as Chromedriver is specifically for Chrome, how can one determine the ap ...

Trouble with stroke width in Svg bezier path while using a mask

I'm having trouble hiding part of a path using a mask. When I apply the mask, the stroke width doesn't seem to work anymore. Any suggestions on why this is happening and how to fix it? svg { position: absolute; width: 100%; height: 100%; ...

Executing PHP Code with an External JavaScript File in an HTML Document

I have a script called initialize_database.js that utilizes JQuery to trigger a PHP script for creating a database and some tables. I made sure the PHP script is working correctly by adding HTML to test it independently, and it performed as expected. Below ...

Reveal content as you scroll

I'm having trouble with the code snippet below. My goal is to utilize .cbp-fbscroller in my CSS to show a new side navigation menu on my HTML page only when scrolling down to 900px. However, as someone who is new to JavaScript, I am struggling to make ...

Sort slider items using Show/Hide feature in bxSlider

I am using a bxslider on my website with specific settings: $('#carousel').bxSlider({ slideWidth: 146, minSlides: 2, maxSlides: 6, speed:500, adaptiveHeight: true, moveSlides:3, infiniteLoop : false, hideContr ...

Concealed checkbox value in jQuery

I have a problem with setting the hidden checkbox "marketingPhone" to TRUE when the "marketingAAA" checkbox is checked as true. This part works fine. However, if any other checkbox on the page is set to TRUE, then it also sets "marketingPhone" to TRUE. I ...

Adjust the CSS extension within the about:config settings of Firefox

I've been using the Zotero extension and I want to adjust how TinyMCE handles paragraph spacing. I'm looking to customize the CSS in extensions.zotero.note.css by adding specific CSS rules. The reason I want to make these changes is because I fe ...

Using Selenium with Python to interact with an onclick() button and perform a click action

I am currently encountering an issue with selenium in Python while trying to locate and click on a small plus-button. Unfortunately, I keep receiving a TypeError for some unknown reason. TypeError: 'str' object is not callable The webpage I am o ...

triggering e.stopImmediatePropagation() within an onclick event handler

Is there a way to retrieve the event object from an onclick attribute? I attempted the following: <a href="something.html" onclick="function(e){e.stopImmediatePropagation();}">Click me</a> In addition, I tried this: <a href="something.ht ...

Guide to building a robust tab system using JQuery and Ajax

I am currently working on a mockup page where the accordion feature is functioning well. However, I am looking to implement a tab-like system that will allow users to navigate between different pages. Specifically, I want users to be able to click on page ...

the spillage exhibits only a thin streak of gray

My website is primarily a Single Page Website, however, there are specific pages that can only be accessed by registered users. On the website, there is a section referred to as a "block" where you will find a button labeled "Login / Register". Upon clicki ...

The CSS property input::-webkit-outer-spin-button adjusts the margin-left and is exclusively visible in Chrome browser

Strange things are happening... Let me share the code for my inputs: #sign_in input#submit { height: 56px; background-color: #88b805; font-weight: bold; text-decoration: none; padding: 5px 40px 5px 40px; /* top, right, bottom, left ...

Guide on implementing the recently established attribute ID using jQuery

In my code snippet, I am assigning a new id to a button. Here is the code: $("#update").click(function(){ $("#update").attr('id', 'cancel'); }); After changing the id, I want to make it functional again in jQuery by reverting it b ...

Error in Firefox: "Anticipated media feature name, but discovered 'hover'"

I am trying to style elements differently based on whether the client browser supports hovering or not. I came across media features as a solution and implemented it in the following way: /* Supports hovering */ @media (hover: hover) { ... } /* Does not ...

What is the best way to display the information contained within a .nfo file on a website?

Does anyone know of a plugin or code that can display the content of a .nfo file on a webpage (html or php)? I want to create multiple web pages with individual .nfo files, but I'm not sure if this is achievable through coding or if there's a scr ...