1
votes

Someone must have done this before, I am trying to work out a comparable command to use in jmeter webdriver sampler (javascript) how to do a waitForPopUp command...there must be a way...I have something that works for waiting for an element, but I can't work it out for a popup..

hope someone can help

thanks

Karl

UPDATE

I am using this code for waiting for an element -

var wait = new support_ui.WebDriverWait(WDS.browser, 5000)
WaitForLogo = function() {
var logo = WDS.browser.findElement(org.openqa.selenium.By.xpath("//img[@src='/images/power/ndpowered.gif']"))     
}
wait.until(new com.google.common.base.Function(WaitForLogo))

And this works, but I can't work out how reuse this to wait for a popup, that has no name, in java I have used -

    selenium.waitForPopUp("_blank", "30000");
    selenium.selectWindow("_blank");

And that works, but I can't work out an comparable javascript that will work in jmeter for performance, as I can't get java working in jmeter.

2
What kind of pop-up it is and what code you use for waiting for an element? - Andersson
have updated my post with some more info for you, thanks for answering.. - Karl

2 Answers

2
votes

I was able to get this working using:

    var sui = JavaImporter(org.openqa.selenium.support.ui)

and:

    wait.until(sui.ExpectedConditions.numberOfWindowsToBe(2))
1
votes

In WebDriver Sampler you have the following methods:

  • WDS.browser.switchTo.frame('frame name or handle') - for switching to a frame
  • WDS.browser.switchTo.window('window name or handle') - for switching to a window
  • WDS.browser.switchTo.alert() - for switching to a modal dialog
  • WDS.browser.getWindowHandles() - for getting all open browser window handles

See JavaDoc on WebDriver.switchTo method and The WebDriver Sampler: Your Top 10 Questions Answered guide for more details.