Upon pressing a link that opens a new tab, he notices that the buttons and fields are not visible

Here is my issue: When I click on a link that opens in a new tab, switch to the new tab, and try to click on a field to enter text, I encounter the following error message:

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='nameFields']"}

I have attempted various methods, including closing the initial tab (tabs.get(0)).

    public exampleMethod() {
        ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles());
        driver.switchTo().window(tabs.get(0));
        System.out.println("tab 0: " + driver.getTitle());
        driver.close();
        driver.switchTo().window(tabs.get(1));
        System.out.println("tab 1: " + driver.getTitle());
        //driver.navigate().refresh();
        //driver.findElement(By.xpath("//*[@id='nameInput']")).sendKeys("qwerty");
        nameInput.sendKeys("qwerty");
        submit.click();
        return this;
    }
There are no issues with retrieving the page titles.

Answer №1

Make sure to implement a wait before calling nameInput.sendKeys("qwerty") with the provided code snippet

WebElement element = new WebDriverWait(driver, 25).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//[@id='nameInput']")));

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

Exploring the intricacies of Java's advanced data binding capabilities using JSON

I'm currently facing an issue with the @OneToMany bindings and the bindFromRequest method in Java Play. The situation involves a Client model that contains multiple FinancialAsset models @Entity public class Client extends Model { ... @OneToMany(cas ...

Is it feasible to automate the cropping process with selenium?

Exploring a new challenge: simulating a cropping feature. I understand that replicating human cropping is impossible, but the image I intend to crop remains a fixed size each time I run the test. My goal is to establish the cropping WebElement at a constan ...

Is it possible to terminate a Windows process directly from a Protractor specification?

Dealing with the timing bug in Firefox's Plugin container can be quite a headache. I'm looking for a solution to kill it before closing the browser. Ideally, something like: Runtime().getRuntime().exec("taskkill /f /im WefFault.exe") But I ne ...

The Dynamic Duo: Selenium and Angular

Trying to test an Angular website has presented a challenge. The issue lies in the inability to click on an element due to no action being taken. This prevents Selenium from finding the element using By.xpath. View the screenshot below for reference: Upon ...

Is there a way to extract text from tooltips using selenium even if the page does not have tooltip HTML code?

My current challenge involves scraping item details from a webpage using Selenium. Specifically, I am facing difficulties with extracting text from the item tooltip. When inspecting one of the items on the page using developer tools (F12), the HTML struct ...

Unable to locate the Selenium server

After setting up the latest Selenium Standalone Server (3.0.0-beta2) on my Windows Server 2012 R2 Standard machine, with Java version "1.8.0_101" installed, I ran into an issue. Despite executing the JAR file using the command: java -jar selenium-server-s ...

Hiding Chrome browser during VBA web scraping in Excel: techniques for seamless code execution

Can anyone tell me if it's possible to use Chrome or Edge with Selenium in Excel VBA for web scraping without displaying the browser window like you can do with Internet Explorer by setting IE.Visible = False? Thanks! ...

Using the following-sibling selector in Java, you can easily click on all <li> elements within a <ul> tag

I am trying to navigate through the list of li elements starting from the "Mentorship" tag link <ul _ngcontent-cwp-c18="" class="navigation clearfix"> <li _ngcontent-cwp-c18="" routerlinkactive="current" ...

Unable to automate button clicking in Java with Selenium WebDriver

I am facing a challenge with testing two buttons within a form. The buttons are as follows: <div class="ef-buttons"> <button value="next" name="action" type="submit"> Continue </button> <button id="modify_button" value="previo ...

Encountered an issue when parsing JSON in Spring Boot: Unable to deserialize the

I'm encountering issues when trying to submit the form. Despite making changes in RoominfoController to accommodate arrays, the problem persists. Cannot deserialize value of type `com.example.pgfinder.models.RoomInfo` from Array value (token `JsonToke ...

While utilizing Internet Explorer, a SessionNotFoundException was encountered when attempting to call a function in Selenium

Having an issue with a login function that is throwing a session not found exception even though I have saved Login as a library. import lib.Login; public class MessageBoard { WebDriver driver; @BeforeMethod public void initialize() { System.setProp ...

Navigating between different browser windows in Selenium can be achieved

In my application, I have a scenario where I need to switch between three windows. The switching code works fine when I open the first window and then move to the second window. However, I encounter an issue when trying to switch from the second window to ...

What is the process for extracting content from CSS comments or annotations in a stylesheet?

Here's an interesting concept: allowing users to define a set of CSS rules with annotations. For example: /* @name Page style */ body { font: 16px/1.5 Arial; /* @editable */ background-color: #fff; /* @editable */ } /* @name Section header */ ...

Collecting Payment Information using Python's Selenium Automation

This question is a continuation of my previous inquiry Click here for details on dynamic elements I am currently working with Python and Selenium to navigate to a webpage and input Credit Card information. Unlike my previous question where the element ha ...

Evaluating CSS Specificity

Is there a recommended approach for automatically testing css selectors? I am in the process of developing a SCSS framework and I want to integrate automated tests. Specifically, I aim to verify that the css selectors are functioning correctly. For examp ...

Selenium Python: Overcoming Errors in Xpath Loop Element Retrieval

Currently in the process of creating a web scraper specifically for Pinterest. The majority of data has been successfully gathered, however, each pin includes a "see more" button that reveals additional information such as the 'board name' and &a ...

Python Selenium Requests not working properly

I am a beginner with selenium and trying to figure out what I'm doing wrong in my code. from selenium import webdriver from selenium.webdriver.common.keys import Keys import time driver = webdriver.Chrome(executable_path="C:\\Users&bsol ...

Tips for selecting an item from a dropdown menu that is not in select format using Selenium in Python

How can I interact with the dropdown menu button located in this HTML code? <div id="menu-button-:r1p:" aria-expanded="true" aria-haspopup="menu" aria-controls="menu-list-:r1p:" class="chakra-menu__menu-butto ...

Jackson ObjectMapper configured to represent JSON data in array format without using annotations

Is there a way to use two Jackson 2 object mappers for the same set of classes? The first mapper needs standard serialization, while the second should use the ARRAY shape type for all classes. I want to globally set this feature for my second ObjectMapper, ...

The Selenium Internet Explorer driver is experiencing difficulties in successfully interacting with the "Sign In" link

I crafted the following code snippet to log in to the [""][1] using selenium IE webdriver (64 bit) and IE 11 browser. However, I am encountering an issue where the selenium IE webdriver is unable to click on the 'Sign In' link. Can anyone assist ...