Experiencing Difficulty accessing Methods with 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 support_page=JavaImporter(org.openqa.selenium.WebDriver.Timeouts)**
**var support_p=new support_page.pageLoadTimeout(30, TimeUnit.SECONDS)**
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()
//button.click()

Even though I managed to import the WebDriver.Timeouts class successfully, I encountered an issue trying to access the Method pageLoadTimeout. When running JMeter, it kept showing the error message:

Response message: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "TimeUnit" is not defined. (#5) in at line number 5

I am seeking assistance to resolve this problem and enable JMeter to access the pageLoadTimeout() method properly.

Answer №1

Discover a simpler and more efficient approach to completing tasks. Give the code below a try:

var timeunit = java.util.concurrent.TimeUnit

WDS.sampleResult.sampleStart()
WDS.browser.manage().timeouts().pageLoadTimeout(1, timeunit.SECONDS);
WDS.browser.get('http://google.com')
WDS.sampleResult.sampleEnd()

For further insights into scripting with Selenium in Apache JMeter using the WebDriver Sample plugin, check out Using Selenium with JMeter's WebDriver Sampler guide.

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 functionality of an HTML form utilizing JavaScript struggles to function correctly when integrated with PHP

I created a form with JavaScript that allows me to toggle between different fields based on the selection made with radio buttons. <?php require_once 'resources/menus/adminMenu.php'; ?> <div class="col-lg-offset-3 col-lg-6 "> < ...

Combine large arrays

Hey, I'm encountering some issues while trying to merge large arrays in a React Native app. Specifically, I am attempting to implement infinite scroll on React Native. The issue arises when the array reaches 500+ items; every time I add more items, my ...

Customized queries based on conditional routes - expressjs

Can we customize queries based on optional routes? app.get('/:category/:item?', function (req, res) { var category = req.params.category; var item = req.params.item; var sqlQuery = 'SELECT * FROM items WHERE category = ? AND item = ?&a ...

Tap to reveal additional information with the power of Jquery and ajax

I have a question regarding the popup slide functionality. I would like to achieve the following: Currently, I am using the following code to display post details upon clicking: function getPostDetails(id){ var infoBox = document.getElementById("in ...

Refresh the image source using the AJAX success callback

Previously, I was updating Label values within the AJAX success function as shown below. Now, I am looking for a way to use the same method to change or update the "src" attribute of an <img id="myimage" src=""/> $.ajax({ url: 'clmcontrol_l ...

Learning how to implement server side rendering in React JS through tutorials

After diving into the world of React js and mastering the basics, I successfully created web pages using this technology. I also honed my skills with node js and express. However, now I am faced with a new challenge: server side rendering. The tutorials av ...

Convert a string with the characters '"' retrieved from a MySQL database into JSON

After creating a JSON object and storing it in MySQL, I encountered an issue when trying to retrieve and parse it. When I stringify the JSON object, the properties are being enclosed in double quotes causing issues when parsing the retrieved string. Below ...

Guide to modifying the root directory when deploying a Typescript cloud function from a monorepo using cloud build

Within my monorepo, I have a folder containing Typescript cloud functions that I want to deploy using GCP cloud build. Unfortunately, it appears that cloud build is unable to locate the package.json file within this specific folder. It seems to be expectin ...

Is there a way to automate the downloading of a PDF file from a webpage that has a .html extension?

After thoroughly reviewing all related inquiries across various forums, I have diligently attempted numerous methods to programmatically download a test file from: Below is the direct URL of the specific test file that I am endeavoring to retrieve. This t ...

JavaScript struggles when dealing with dynamically loaded tables

I am currently working on integrating the javascript widget from addtocalendar.com into my website. The code example provided by them is displayed below. Everything functions as expected when I place it on a regular page. However, I am facing an issue wher ...

How do I add a "Switch to Desktop Site" link on a mobile site that redirects to the desktop version without redirecting back to the mobile version once it loads?

After creating a custom mobile skin for a website, I faced an issue with looping back to the mobile version when trying to add a "view desktop version" link. The code snippet below detects the screen size and redirects accordingly: <script type="text/j ...

Having trouble displaying a table accurately in React

My goal is to create a table with Material UI in React, similar to the one shown in this image: https://i.stack.imgur.com/QIV8o.png Below is the code I have written so far for this table: return ( <> <div className="main-wrapper& ...

The width of an HTML input and button elements do not match

Currently, I am facing an unusual issue where my input and button tags seem to have the same width assigned to them (width: 341.5px; calculated from $(window).width() / 4) in the code, but visually they appear to be of different widths. Here is a visual re ...

Tips for accessing .js variables in .ejs files

I am facing an issue with my index.js and list.ejs files in Express. Here is the relevant code: index.js: const express = require("express"); const app = express(); app.set("view engine", "ejs"); app.set("views", __dirname + "\\views"); let ...

A guide on decoding neatly formatted JSON using GSON

Currently, I am interfacing with various APIs that produce JSON responses formatted in a "prettyprinted" manner rather than the standard one-line format. For instance: [ { "Field1.1": "Value1.1", "Field1.2": "value1.2", "Field1.3": "Value1. ...

How can I set up caching for my nodejs - selenium automation script?

I'm currently working on developing a macro that can automate the process of opening the browser, accessing my Outlook account, exporting my planner data to Excel, and then saving it in the same folder. const {Builder, By, Key, until} = require(&apo ...

The Year as a Reference Point

I came across an interesting issue while working with dictionaries and JSON in sessionStorage. Initially, I had a dictionary structured like this: "name" : { "2016" : { "1" : "info" } } After successfully adding it to sessionS ...

Is there a way to differentiate between a browser application running on a local development server and an online staging server?

Is there a way to conditionally call a component only on the staging server and not on the local machine in Vue.js? <save-drafts-timer v-if="!environment === 'development'" /> ... data () { return { environment ...

Is there a way to upload a kml file to Google Maps using my website or by using JavaScript commands?

I have information on my website regarding gas stations, including the quality of gasoline and the GPS coordinates of each station. My concept involves incorporating Google Maps into my site, similar to how flightradar24.com displays pins indicating gas s ...

Nesting ng-repeat within another ng-repeat for dynamic content generation

I am currently working on a page that requires displaying boxes (using ng-repeat) containing information about channels and their corresponding cities. The issue I am encountering arises when repeating the second ng-repeat: <table class="table table-c ...