Guide on utilizing sendkeys for interacting with child windows in Salesforce with Selenium WebDriver

How can I use the sendkeys method on a search textbox located in a child window shown in these screenshots?

I have successfully identified the URL and title of the child window, however, whenever I attempt to perform click or sendkeys actions in the child window, the code stops midway with the error message:

org.openqa.selenium.NoSuchElementException: no such element

Please provide suggestions on how to address the issue mentioned above.

Answer №1

It is my hope that there will be no frame, and if this opens in a new window, please follow the steps below:

Thread.sleep(2000);
// Save the current window handle
String winHandleBefore = driver.getWindowHandle();

// Perform the action that triggers the opening of a new window

// Switch to the newly opened window
for(String winHandle : driver.getWindowHandles()){
    driver.switchTo().window(winHandle);
}

// Perform the necessary actions on the new window
driver.findElement(By.xpath("your xpath for the search box")).click();
driver.findElement(By.xpath("your xpath for the search box")).clear();
driver.findElement(By.xpath("your xpath for the search box")).sendKeys("your text");

// Close the new window if it is no longer needed
driver.close();

// Switch back to the original browser (the first window)
driver.switchTo().window(winHandleBefore);

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

BeautifulSoup does not recognize circular HTML pages

Encountered an issue where the page parsing code consistently checks the same page every time, despite using it alongside selenium. Selenium has no problem opening new links, but the parsing only occurs on the initial page. The frustrating part is that si ...

Press the Concealed Button Enclosed in a div Using Selenium with Python

Currently, I am in the process of automating the login on the Workday portal by utilizing Chrome WebDriver in Selenium. My main challenge lies in figuring out how to click on a hidden sign-in button with the following properties: <div class="css-1s ...

What is the best way to manage alerts using Python?

I want to manage alerts using Python. Here's what I aim to achieve: Open a URL Submit a form or click on links Verify if an alert is triggered on the new page In the past, I accomplished this task using Javascript with PhantomJS. However, I am now ...

What is the process for selecting a hidden element in Selenium WebDriver using C#?

I need help with the following code snippet: Actions builder = new Actions(driver); builder.MoveToElement(driver.FindElement(By.LinkText("Master Data"))).Build().Perform(); driver.FindElement(By.LinkText("Suppliers")).Click(); Unf ...

Display all active ajax/http requests using Javascript or JQuery

Currently, I am constructing a test suite with Selenium. In case of a failed test, I require the ability to determine which vanilla http requests and ajax requests are still in progress. Is there a method to interrogate the browser directly and retrieve a ...

Newer builds of selenium/node-chrome have disabled hardware acceleration

I am currently in the process of updating the browser image used for our selenium tests from node-chrome:3.141.59-20201119 to node-chrome:3.141.59-20210607. However, I have encountered an issue with the newer version as hardware acceleration is not enabled ...

Encountering a TimeoutException while utilizing Selenium in Python

Utilizing WebDriverWait in my script involves two different instances with the same syntax. The first time I use it is to check for any typos within a defined class, while the second time is under a function nested within the same class. Surprisingly, an e ...

Tips for choosing a dropdown option and clicking on specific values in a dropdown menu using Selenium WebDriver with Java programming

Below is a snippet of HTML code. In this code, with the help of Java Selenium, I am trying to automate clicking on the logout option to end the session. The process involves clicking on a dropdown button which reveals the logout option, and then clicking o ...

Sauce Labs encountering issues when running JavaScript code

Currently, I am using Selenium WebdriverJs along with Mocha to conduct tests on Sauce Labs via Travis CI. After isolating the issue without any project dependencies, I am seeking help. The interesting observation is that defining an additional object with ...

Obtain the thread number of the current wdio instance

My automated UI tests run in parallel using the wdio maxInstances, generating a unique mobile number at the start of each test. 07 - All numbers start with this number. Next is a 9-digit number based on time & date - `new Date().getTime().toString(). ...

The DevToolsActivePort file for Selenium on Heroku cannot be found

I'm currently in the process of deploying a node and selenium application to Heroku. Here is a snippet of my code: let options = new Options(); options.setChromeBinaryPath(process.env.GOOGLE_CHROME_BIN); options.addArguments("headless"); options.addAr ...

How to Use RemoteWebDriver Instance in PHP for Parsing Tables with Selenium Webdriver?

Hello there! I am looking to extract data from a table with the following structure: <table> <tbody> <tr> <td class="seo-company-label">Name</td> ...

Unable to input letters "d," "e," or "f" using the sendkeys function on Safari version 17.3.1

Currently, I am utilizing safaridriver that comes with Safari 17.3.1 (19617.2.4.11.12) and have encountered no issues with the latest editions of Chrome, Edge, or Firefox. The problem arises when I attempt to input "def" using SendKeys in a textarea on my ...

One of the @Test code sections is not being executed

I'm having trouble getting the TocheckApproval() code block to run Could someone provide some insights on why this might be occurring and what actions I should take to ensure both @Test blocks are executed successfully? ...

Unable to navigate between windows in Webdriver using C# and CSharp

I'm facing an issue with switching windows using the latest version of Selenium WebDriver in C#. The scenario is that I have a base window, and upon clicking a button, it opens a new window. Here is the code snippet for opening the new window: wind ...

Exploring the contrast between the JsonWireProtocol mechanisms and the latest standards outlined in the W3C Living Document in the context of

Curious about the distinctions between the functionalities of JsonWireProtocol (now considered OBSOLETE) and the latest W3C Living Document dated 31 December 2019 (the updated standard) when utilizing Selenium for conducting UI tests. The process of initia ...

Trouble finding an element with Xpath on Android hybrid apps using Appium?

I am in the process of automating a hybrid app using Appium. My app was built with Ionic Framework and I have completed all the necessary setup. When inspecting the elements with Firebug in Mozilla, I found the xpath for a specific button to be //Button[te ...

Switching the proxy server within Selenium automation

It appears that everything is functioning properly. fp = webdriver.FirefoxProfile() fp.set_preference("network.proxy.type", 1) fp.set_preference("network.proxy.http", PROXY_HOST) fp.set_preference("network.proxy.http_port", int(PROXY_PORT)) fp.update_pref ...

Storing a group of IWebElements as a collection in C# with Selenium by utilizing the [FindsBy] attribute

I'm struggling with setting multiple IWebElements to a collection using the [FindsBy] attribute from OpenQA.Selenium.Support.PageObjects. Specifically, I am trying to store all "li" elements in an instance variable called "MyElements". HTML <ul c ...

Tips for choosing an element within a Span tag using xpath or css selector

Is there a way to automate the process of pinging a specific person on a messenger by selecting their name, Nayan? Here is the HTML code snippet: <div class="Presence__text"> <span class="Presence__nameText">Nayan<span c ...