Performance testing with JMeter and Webdriver on multiple browser windows

Looking for help with JMeter and Webdriver to record UI tests. Stuck on selecting a popup window due to Javascript issues...

Here is the current code snippet:

var pkg = JavaImporter(org.openqa.selenium)
var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait)
var driver = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait)
var wait = new support_ui.WebDriverWait(WDS.browser, 5000)

WDS.log.info("Opening page...");
WDS.browser.get('XXXX')

var userField = WDS.browser.findElement(pkg.By.id('userid'))
userField.click()     
WDS.log.info("Clicked user field")
userField.sendKeys(['XXXX'])

var passField = WDS.browser.findElement(pkg.By.id('password'))
passField.click()     
WDS.log.info("Clicked pass field")
passField.sendKeys(['XXXXX'])

var loginButton = WDS.browser.findElement(pkg.By.cssSelector('input[type=\"image\"]'))
loginButton.click()

var quickEntry = WDS.browser.findElement(pkg.By.linkText('Quick Entry'))
quickEntry.click()


var handles = WDS.browser.getWindowHandles()
var iterator = handles.iterator()
var counter = 1;
while (iterator.hasNext())
{
var handle = iterator.next()
WDS.browser.switchTo().window(handle)
 WDS.log.info('Window ' + counter + ' title = ' + WDS.browser.getTitle())
counter++;
}

WDS.browser.switchTo().window('APC Overnight Demo Online')

var reference = WDS.browser.findElement(pkg.By.name('preselect'))
quickEntry.sendKeys(['TEST'])

The issue is that it fails to switch to the popup window after clicking "Quick Entry", resulting in the inability to locate "preselect"...

Seeking guidance from someone who might spot what I'm missing here.

Thank you

UPDATE - Revised the code as per suggestions, but encountering the following error detailed in the log below. The code correctly identifies the window name "APC Overnight Demo Online" but facing an error stating it cannot find a window with that name?

2016/12/19 14:25:51 INFO  - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: Opening page... 
2016/12/19 14:25:51 INFO  - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: Clicked user field 
2016/12/19 14:25:51 INFO  - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: Clicked pass field 
2016/12/19 14:25:52 INFO  - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: Clicked login 
2016/12/19 14:25:52 INFO  - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: Clicked quick entry 
2016/12/19 14:25:52 INFO  - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: Window 1 title = APC Overnight Demo Online - Home Page 
2016/12/19 14:25:53 INFO  - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: Window 2 title = APC Overnight Demo Online 
2016/12/19 14:25:55 ERROR - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: Unable to locate window "APC Overnight Demo Online"

Answer №1

Your code for managing windows is spot on, closely resembling the solution provided in the article "Q. How do I Switch Between Windows in the WebDriver Sampler?" found in The WebDriver Sampler: Your Top 10 Questions Answered guide.

If you're having trouble switching to your "popup" window, it's possible that it's not actually a window but an iframe. In this case, consider checking the following options:

  • WDS.browser.switchTo().frame("iframe name")
  • WDS.browser.switchTo().activeElement()

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

The video on Videojs fails to show up on the screen

Currently utilizing the most recent version of videojs. Referencing this example http://jsfiddle.net/swinginsam/NWbUG/#share Access source code Having trouble identifying the issue. <!DOCTYPE html> <html> <head> <title>Video.j ...

What is the suitable condition necessary for optimal functionality?

Greetings all! I am a newbie in the world of development and also new to Stack Overflow. This is my maiden post seeking assistance on the following issue: $(document).ready(function() { $(".header").click(function() { if ($(".header-content"). ...

Adding a new key and value to my JSON dataset

I received the JSON response below: { "PatientSearchResult": { "Patient": [{ "AccountBalanceCalcMethod": 2, "AlternatePatientID": 0, "AssignmentOfBenifits": 0, "CellPhoneNumber1": null, ...

Is there a way to access a component based on the parameter in the Vue router?

I am working on a Vue component called Portfolio.vue, which contains a child component called Category.vue. I am able to navigate to the Category.vue component using <router-link :to = "{ name: 'category', params: { id: id }}"> wh ...

Is it possible to utilize AngularJS' ng-view and routing alongside jade?

Currently, I am diving into the world of the MEAN stack. I noticed that Express utilizes jade by default, but I decided to experiment with it even though I can easily use html instead. When attempting to route with Angular, like so: ... body div(ng-view ...

Unveil Secret Divs with a Click

I am in search of a way to display a hidden div when I click on a specific div, similar to the expanding images feature in Google's image search results. I have made progress with my limited knowledge of javascript, as shown in this CodePen: http://co ...

Combining query results/objects by id in an array within a React application with Firebase Firestore

After retrieving chat messages from a Firestore snapshot, I have the following query result involving conversations among three individuals: {timestamp: "October 25th 2020, 11:13:59 am", name: "John Doe", email: "<a href="/cdn ...

"When attempting to invoke the robot class, an invalid StackMap error with code JVMCFRE006 is typically thrown within the

Code: public int closeWindow(WebDriver driver) { int status = 0; try{ Robot robot=new Robot(); robot.keyPress(KeyEvent.VK_ESCAPE); robot.keyRelease(KeyEvent.VK_ESCAPE); status = 1; } ...

"Error 404: Invalid request encountered while using React and

I am encountering an issue with a 404 not found error when I attempt to send a post request in React. My code involves using Django Rest Framework on the backend and React Axios on the frontend, but I am facing errors while making the post request. Below i ...

What is the best way to display data from multiple lists that are returned by a JSON function?

List of My Models: ClassAllocate: Contains Id, DepartmentId, CourseId, RoomId, DayId, StartTime, EndTime Course: Consists of Id, CourseCode, CourseName, DepartmentId Room: Includes Id, RoomNumber Day: Has Id and DayName My goal is to search for course ...

Issue with Ionic app causing code execution to hang when the Back Button is pressed

I am currently working on an application using Ionic and React. There is a page in the app where users can upload images from the camera or gallery, which are then saved as binary data in a database (indexed db using Dexie). Everything seems to be function ...

Assistance required in designing a unique shape using Three.js

https://i.sstatic.net/pmHP2.png Hello there! I could use some assistance with replicating the 2D shape shown in the image above using three.js. Specifically, I'm encountering some difficulty with incorporating the subtle curvature seen on the inner l ...

Smooth scrolling feature malfunctioning in mobile view

While working on my website, I noticed that the smooth-scroll feature works perfectly on desktop browsers. However, on mobile devices, when I click on a link, it does not scroll to the correct position. It always ends up much lower than expected. Any idea ...

Is there a feature similar to Nuxt.js' auto-register in Next.js?

My Journey as a Beginner Being a beginner in the tech world, specifically in full-stack development (although I'm about 8 years behind), I find myself grappling with the decision of what to focus on learning. Vue and Nuxt.js are fantastic technologi ...

Retrieving data from PHP MySql Query and importing it into JavaScript

Currently, I am in the process of developing a count-up timer for one of our office dashboards that tracks the time since the last incident or reset. There is a page dedicated to allowing senior admins to input a new timestamp. This timestamp then gets up ...

Using THREE.js to cast rays from a secondary camera onto the scene

I've been attempting to raycast the mouse from my camera in order to trigger hover and click events on meshes within my scene. The issue I'm facing is that my camera is currently a child object of another mesh (to facilitate easier camera moveme ...

"Developing a Python web scraper using Selenium that disables the Enter key functionality in the search bar

I'm currently attempting to extract data from this particular website by company, however, the search functionality seems a bit glitchy. My approach involves waiting for the element to become visible, but I'm struggling to accomplish this task. ...

Optimal approach for handling large JSON files

I am in possession of a JSON file containing approximately 500 lines. I am hesitant to simply dump this JSON data into the end of my Node.JS file as it doesn't seem like the most efficient approach. What alternatives or best practices can be recommend ...

Potential risk of memory leakage when utilizing the CanvasRenderer

I've encountered a memory leak problem within my application. After some investigation, I've been able to simplify the issue into a test case found here: http://jsfiddle.net/729sv/ It seems that adding and removing geometry from a scene is causi ...

Access the JavaScript variable in a webview and store it in an Android variable

I have been attempting to retrieve a variable from a webview, but I am only able to make modifications like this: browser.loadUrl("javascript:var x = document.getElementById('login').value = 'something';"); However, I need to be able ...