Selenium - "element out of sight" due to reduced specificity

Recently started working with Selenium and selenium-webdriver. I'm attempting to open Google and click on an anchor tag. See the code snippet below:

var webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder().
   withCapabilities(webdriver.Capabilities.chrome()).
   build();

driver.get('https://www.google.com/');
driver.wait(function () {
  return driver.isElementPresent(webdriver.By.css('a'));
}, 2000);
driver.findElement(webdriver.By.css('a')).click();  

driver.quit();

Selenium is throwing an

ElementNotVisibleError: element not visible
error for the selector 'a'.

However, when I use the more specific selector '#fsl>a', Selenium is able to click the item.

Any suggestions or pointers would be greatly appreciated.

Answer №1

Illustrating that although an element exists in the DOM, it is not visible, hence cannot be interacted with.

I found assistance in ElementNotVisibleError to troubleshoot the issue.

The problem lies in visibility, not specificity.

Upon executing document.querySelector('a'), the initial a element returned is not visible within the document.

https://i.sstatic.net/uyXTr.png

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

Comparing Redux with passing state down to components as props from the top level of the application

With limited experience in react-redux, I am currently working on a smaller web-based application intended for around 100 users. At this time, I have opted not to use redux due to concerns about its complexity for such a small project. Instead, I have been ...

Utilizing JavaScript for the removal or hiding of span elements with specific class attributes

I am currently working on a software project that involves compiling HTML fragments and then exporting them to Microsoft Word. My goal is to create a script that will cycle through these compiled fragments and remove specific tags that have a particular CS ...

The 404 Page Not Found error is displayed when an Angular JS Encoded URL

I have successfully developed an AngularJS application. The application functions properly with the URL provided below: http://localhost/AngularDemo/about However, when I try to modify the URL as shown below, it redirects me to a 404 error page: http:/ ...

Oops! An error occurred: Uncaught promise rejection - invalid link found for ProductListComponent

I am currently in the process of learning Angular and Ionic, but I am feeling a bit confused as to where my mistake is. I have looked at other questions, but I still can't seem to figure it out. Can anyone provide some assistance? Perhaps someone has ...

How to redirect in Next.js from uppercase to lowercase url

I'm trying to redirect visitors from /Contact to /contact. However, following the instructions in the documentation results in an endless loop of redirects. This is my attempted solution: // next.config.js async redirects() { return [ { ...

Having trouble with a lengthy formula in your Google Sheets Apps Script function? You may encounter an error like `SyntaxError: missing ) after argument list line: 14 file: new line.gs`. Let

The Apps Script function being discussed: function insertNewRow() { var ss = SpreadsheetApp.openById("redactedforprivacy"); var sheet = ss.getSheetByName("Main"); sheet.insertRowBefore(2); var date = new Date(); var month = date.getMonth() + 1 ...

Can you please explain the concept of straightforward UI routes to me?

I recently discovered that ui-routes are more powerful and advantageous than ngRoutes. In an effort to learn more about the ui-routing feature, I started studying from http://www.ng-newsletter.com/posts/angular-ui-router.html. However, I found it challengi ...

Transferring information between components within AngularJS

export class AppComponent { title = 'shopping-cart'; ngOnInit() { } images = [ { title: 'At the beach', url: 'https://images.unsplash.com/photo-1507525428034-b723cf961d3e?ixlib=rb-4.0.3&ixid=MnwxMjA ...

Error: Ajax unable to parse JSON - property 'name' does not exist in the object

When accessing my report.php file, it returns a json data. Here is the snippet of javascript code I am using to try and read the json: <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script> $(document).ready(function ...

Unable to locate any input field, despite attempting to find it using a class name, xpath, and css selector

After multiple attempts, I am still unable to locate this particular input element. <div class="col-sm-8 col-lg-10 fb-field-container " style="min-height:26px"> <div class="fb-inline-field-container form-line" sty ...

Struggling to retrieve information from a JSON file and display it within a component?

After accessing the JSON data and storing the necessary values in a dictionary named details, I am encountering an issue where the values are displayed when console logged from inside the function but appear as undefined when console logged in the parent f ...

Prepending a string to the key of a JSON object using JavaScript

Is there a way to add 'd:' before the key of a JSON object? Here is the JSON data: "data": { "aa": "value", "ab": "value" } The expected result should look like this: "d:data": ...

nyroModal automatically adapts its dimensions according to the size of the webpage, not the size of

A situation has arisen with a link that opens an image using nyroModal. While everything is functioning correctly, the Modal window appears in the center of the page instead of aligning with the middle of the browser window. As a result, only the upper por ...

Why does my node-js API's second endpoint not function properly?

Currently working on my first API project. Everything was going smoothly, until I encountered an issue with my second route, app.route('characters/:characterId'). For some reason, none of the endpoints are functioning, while the first route, app. ...

The HTML div captured with html2canvas is incomplete

I am currently developing a meme editor website utilizing the html2canvas library available at Below is the HTML code for the div I aim to capture: <div class="container"> <div id="theUserMeme"> <div class=& ...

Retrieve a form (for verification purposes) from a separate AngularJS component

I'm facing an issue with accessing a form from one component to another in my project. One component contains a form, and the other has navigation buttons that, when clicked, should validate the form before moving on to the next step. However, I alway ...

I'm curious if there is a method in React Native to dynamically alter the color of a button depending on a boolean value retrieved from a database source

Hey there, I'm completely new to React-Native and just started playing around with it. I encountered an issue where I needed a button to change its color dynamically between "green" and "red" based on a boolean value from a database. Currently, I am ...

Unable to transfer the variable name between different node modules for the purpose of using it as a chat room identifier in a socket.io application

Users are able to provide a room name, however when using module.exports in a separate file to retrieve it, the value shows as undefined. This issue likely arises from the asynchronous nature of the process. //roomcheck.js var nsp = io.of("/gameroom"); n ...

Access the value of a variable from a window resizing event and utilize it in a different

I have a carousel that I'm working with and am trying to figure out how to announce the number of currently visible slides when the "next" button is clicked. While I can see that on resize, the correct number of slides is being logged, I am strugglin ...

Is there a solution to prevent the "NavigationDuplicated" error in Vue.js when adding query parameters to the URL without changing the path?

Presently, the URL shows /search The new URL should display /search?foo=bar I am looking to modify my query parameters on the current route after applying some filters on the page. This is my code: this.$router.push({query: params}) Although I can h ...