Saravana
Saravana

Reputation: 147

Is there any command for page to load completely in Jmeter Webdriver

var pkg = JavaImporter(org.openqa.selenium)
var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait)
var wait = new support_ui.WebDriverWait(WDS.browser, 5000)
var url = WDS.args[0];
var user = WDS.args[1];
var pwd = WDS.args[2];

WDS.sampleResult.sampleStart()
WDS.browser.get(url)
var wait=new support_ui.WebDriverWait(WDS.browser,15000)
var userName = WDS.browser.findElement(pkg.By.id('Login_txtUserName')).sendKeys([user])
//userName.click()
//userName.sendKeys(['pandian'])
var userPwd = WDS.browser.findElement(pkg.By.id('Login_txtPassword')).sendKeys([pwd])
//userPwd.click()
//userPwd.sendKeys(['1234'])
var button = WDS.browser.findElement(pkg.By.id('Login_btnLogin')).click()

if i execute the above code it's working fine, but what happen is when the browser is open the page is not loading completely it's just navigating to another element, so i want the page to load completely, "Is there any command available for JMETER" bcoz the command in jmeter differs from selenium webdriver.... Please provide the command

Upvotes: 1

Views: 6676

Answers (1)

Ophir Prusak
Ophir Prusak

Reputation: 1447

Yes, you can add a "wait for element" webdriver command to wait until a certain element is viewable / clickable etc. Using the wait.until command.

Here is an example:

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

WDS.sampleResult.sampleStart()

WDS.browser.get("http://www.somesite.com/browse/product.php?pid=12345");
WDS.browser.findElement(pkg.By.id("addToBagBtn")).click();

wait.until(pkg.ExpectedConditions.elementToBeClickable(pkg.By.id('inlineBagCheckOut2')))

WDS.sampleResult.sampleEnd()

Upvotes: 2

Related Questions