The ElementNotVisibleException error was triggered because the element is currently hidden from view, making it unable to be interacted with through the command

I'm facing an issue when trying to clear the text box. The error message I am receiving is:

org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with Command duration or timeout: 30.14 seconds

Below is the HTML code snippet in question:

<input id="cardZipCode" class="padding-left8" type="text" autocomplete="false" maxlength="5" value="10251" name="cardZipCode"/>

The method I am using involves checking for the element's ID attribute. Interestingly, while the textbox is enabled, it appears that it is not displayed. Consequently, attempts to clear the text box result in the

org.openqa.selenium.ElementNotVisibleException
.

Furthermore, I have also tried utilizing the following JavaScriptExecutor code:

JavascriptExecutor js = (JavascriptExecutor) driver;  
js.executeScript("document.getElementById('cardZipCode').value = ' ';");

Unfortunately, this approach yields the same error.

If anyone has insights on how to resolve this issue, your assistance would be greatly appreciated. Thank you!

Answer №1

An error occurred in the main thread: org.openqa.selenium.ElementNotVisibleException. This means that the element is not currently visible and cannot be interacted with. The command duration or timeout was 30.14 seconds.

Here is the code snippet:

       WebElement tab = driver.findElement(By.xpath("//*[@data-toggle='tab' and @href='#admin_tab']"));
    String tabname = tab.getText();
    tab.click();
    Thread.sleep(4000);
    if(tabname.equals("Admin"))
        {
        System.out.println("User has successfully logged in as admin!");
        ***WebElement adminTab = driver.findElement(By.xpath(".//*[@id='admin_admin_nav']/a"));***
        String text = adminTab.getText();
        System.out.println(""+adminTab);
        adminTab.click();

        if(text.equals("Admin"))
        {
            System.out.println("The user has navigated to the Admin>Admin tab successfully!");
        }
        else
        {
            System.out.println("The user is on another tab.");
        }
        }
    else
    {
        System.out.println("The user is not an admin."); 
    }

The HTML code of the application for this action can be found at: Users

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

Excluding a Spec File in Your Protractor Configurations

I have a scenario where I have 10 spec files all named *********.test.js. I need to run tests on all 9 of these files, excluding the file named Idontwantyou.test.js. Currently, I am locating my spec files in the config.file using: specs: ['*.test.js ...

cordova and nodejs causing a communication problem

As a UI front end Developer, my expertise lies in user interface design rather than server side and port connections. I have successfully created a node server.js file that looks like this: var app = express(); var http = require('http').Server( ...

Stop the duplication of the HTML content to ensure only one copy is saved

Recently, I have been coding a feature that saves the HTML of the currently displayed page to another file upon pressing a button. However, I encountered an issue where if the button is pressed multiple times quickly, the saved file contains incorrect HTML ...

Transform the header style columns of react-js Material-tables into rows

Currently experimenting with gradient designs on a material table. While I am able to apply the right color combination to the rows, I seem to be getting column-based results on the title of the table. Attached is a screenshot of my output for reference. ...

Exploring the best way to use $set in Mongoose for dynamically updating an embedded

I'm currently attempting to create a unique function that can update the value of a specific embedded MongoDB document within an array. The goal is to change the value based on its position. function removeAddress(accountNum, pos) { const remove ...

Hit the ENTER key to run the Robot Framework

Whenever I use the Press Keys method with the locator ENTER, it types out "ENTER" instead of actually pressing the Enter key. There is no search button to press, just a text box. Can someone offer assistance? ...

Is it possible to authenticate a user in Firebase using Node.js without utilizing the client side?

Can I access Firebase client functions like signInWithEmailAndPassword in the Firebase SDK on the server side? Although SDKs are typically used for servers and clients use JavaScript, I need a non-JavaScript solution on the client side. I have set up the ...

Shorten a string once a particular word is found in either Smarty or JavaScript/jQuery

I'm currently working on a website and encountering a minor bug related to the addition of content at the end of some strings. For instance: style="background-image:url({$sub.image});" displays style="background-image:url(http://blablalba.fr/phoenix ...

Tips for ensuring all images are the same size within a div element

https://i.stack.imgur.com/EkmWq.jpg Is there a way to make sure all the images fit perfectly inside their respective border boxes without appearing stretched? I've tried setting fixed height and width within a div, but they always end up looking off. ...

Ways to dynamically eliminate focus around text inputs

I have created an HTML page and here is the link to it: My main goal is to remove the black border around the text input on this page. The challenge I am facing is that the 'things to do' list is generated dynamically, meaning it is empty when t ...

Top method for combining several external JavaScript libraries into a single one using webpack

Recently, I was diving into the world of webpack tutorial and it struck me that in order to combine everything into one module, scripts need to use require('./xyz'). Until now, I've always written individual scripts and loaded them in HTML u ...

Utilizing Node.js, delete the author from the database and then use a GET request to display all

Exploring node and express for the first time. I've been working on an example that utilizes GET and POST methods, but now I want to implement DELETE function to delete a book based on its title. Additionally, I need to introduce another GET method to ...

Node.js & Express: Bizarre file routes

It's quite strange how my local paths are functioning. Let me show you an example of my directory structure: public > css > bootstrap.css public > js > bootstrap.js templates > layout > page.ejs (default template for any page) tem ...

The utilization of ui-view resulted in an error message stating "Failed to instantiate the ui.router

Recently, I've been diving into Angularjs and attempting to organize this plunker by splitting it across different files using ui-view. Let's take a look at my app.js 'use strict'; angular.module('Main', []); angular.modul ...

Modifying an HTML attribute dynamically in D3 by evaluating its existing value

I'm facing a seemingly simple task, but I can't quite crack it. My web page showcases multiple bar graphs, and I'm aiming to create a button that reveals or conceals certain bars. Specifically, when toggled, I want half of the bars to vanish ...

I am looking to create a counter in NextJS that will store its value in a database for persistent storage. How can

In my NextJS and ReactJS project, I am creating a like-counter feature that will keep track of the number of likes a user can give. The maximum limit for likes is set to 100. The count is stored in a FaunaDB. While I have successfully displayed the curren ...

Material Design Forms in Angular: A Winning Combination

I'm currently working on developing a form using Angular Material. This form allows the user to update their personal information through input fields. I am utilizing "mat-form-field" components for this purpose. However, there are certain fields tha ...

Changing the text during a reset process

I've been grappling with this issue, but it seems to slip through my fingers every time. I can't quite put my finger on what's missing. My project involves clicking an image to trigger a translate effect and display a text description. The ...

What is the best way to implement automatic scrolling to the bottom of a materialUI drawer in React after a page refresh?

I am facing an issue with my Material UI Drawer, which contains numerous checkboxes and radio buttons for an advanced search page. Whenever a checkbox or radio button is clicked, it triggers an API request to fetch results instantly without requiring a sub ...

React: The error message "p is not defined" is showing up in the component file due to the no-undef

In my React application, I am looking to display a list of menu items from an array and show the detailed description of each item upon clicking. The array of menu items is stored in a separate file called dishes.js. The menu items are rendered using a Me ...