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

npm-bundle encounters an issue with Error: ENOENT when it cannot find the file or directory specified as 'package.json'

npm-bundle is throwing an error that says Error: ENOENT: no such file or directory, open 'package.json' in my NodeJs project. It works fine if I manually create test.js and package.json, then run npm install followed by npm-bundle. However, when ...

A clever way to bypass the "Choose search engine" prompt using capybara, selenium, and chrome

Upon opening Chrome from capybara, I am encountering this screen: https://i.sstatic.net/TMn6SlwJ.png Since stack overflow images are not working for me, here is the image on imgur: This issue is causing errors in my specs. How can I bypass it? For examp ...

I am experiencing an issue wherein after using jquery's hover() function, the CSS :hover state is not

Following the jquery hover function, the css hover feature ceases to work. In my html, there are multiple svg elements. A jquery script is applied where hovering over a button at the bottom triggers all svg elements to change color to yellow (#b8aa85). S ...

What are some ways to access my AsyncStorage data from any location?

I am utilizing the saga library and storing tokens in AsyncStorage. My goal is to be able to freely access the token retrieved from AsyncStorage in both the loadUserPosts function and the loadPosts function. Where should I add async and how can I correct ...

incorrect encoding of Greek characters due to the multer upload package

When uploading files with Greek characters, the uploaded titles are saved as ΠÏξ Îαξ & ÎαÏÏιμιÏαίοι Here is the code for multer variables inside a js file: const storage = multer.diskStorage({ destination: f ...

Can a JavaScript or jQuery function be triggered on input change to perform a PHP call to check a database?

Is it possible to implement live form validation without a page reload? I am looking to add a function like the one below: <input onchange="validate();"></input> function validate() { // PHP here to check input value against table value o ...

Hover over parts of an image to bring attention to them

I am interested in developing a webpage featuring a black and white image of 5 individuals. When hovering over each person, I would like them to illuminate and display relevant information in a dialog box next to them. Do you have any tips on how I can ac ...

Retrieve the parent document for every item within a Firebase collection group

Transitioning from an SQL background to document storage, I am currently navigating through a Firebase database structure that looks like this: John (doc) Restaurant Reviews (collection) Review 1 (doc) Review 2 (doc) Paul (doc) Restaurant Reviews ...

Angular Material 2 with Customized Moment.js Formatting

Is there a way to display the year, month, day, hours, minutes, and seconds in the input field of my material datepicker? I have successfully customized the parse() and format() methods in my own DateAdapter using native JavaScript objects. Howe ...

Updating a string's value in Angular based on user input

I am currently developing a custom offer letter template that will dynamically update key data points such as Name, Address, Role, Salary, etc based on the selected candidate from a list. The dynamic data points will be enclosed within <<>> in ...

Vue.js blocks the use of iframes

I've come across a peculiar issue where I need to embed an iframe inside a Vue template and then be able to modify that iframe later. The code snippet below shows the simplified version of the problem: <html> <body> <div id="app" ...

Issues with Dojo Dropdowns prevent the selection of values due to identical class values

I need assistance with clicking on the "Down Arrow" element for two different dropdowns. Both dropdowns have the same class name, making it challenging to differentiate between these elements when writing the xpath. Any help would be greatly appreciated. ...

Non-responsive behavior triggered by a button click event (JavaScript)

Help needed with displaying results on the same page for an online calculator I'm creating. Why are the results not showing up as expected? I want users to input 4 pieces of information, have the logic executed, and then display the answers below th ...

Is it possible to utilize AJAX to load the URL and then extract and analyze the data rather than

I had originally created a web scraping method using PHP, but then discovered that the platform I was developing on (iOS via phone gap) did not support PHP. Fortunately, I was able to find a solution using JS. $(document).ready(function(){ var container ...

Access control using Vue.js Cookies

Within my current project, we have both superusers and staff members. The specific task of deleting users is reserved for the superuser role only. This leads me to question whether it is plausible to delete a user by utilizing cookies? ...

Best scenarios for utilizing the new keyword in MongoDB

I'm curious about the behavior of the new keyword in node.js. I understand that it is used to create an instance of my schema in mongoose. However, I noticed that I don't have to use new when performing an update. Can someone clarify when exactly ...

Why isn't the VueJS component loading state getting updated after Canceling an Axios network request?

Within my dashboard, there is a dropdown for filtering dates. Each time a user changes the dropdown value, multiple network requests are sent using Axios. To prevent additional API calls when the user rapidly changes the date filters, I utilize AbortContr ...

Error message in Jenkins and Maven: Main class could not be located or loaded

This is my first time trying to run a maven project using Jenkins, and I encountered the following error in the Jenkins console output: Error: Could not find or load main class MAVEN_HOME ERROR: Failed to launch Maven. Exit code = 1 Finished: FAILURE My ...

What is the best way to handle multiple responses in Ajax within a single function?

Here is a simple code snippet: $.ajax({ url:'action.php', method: 'POST', data:{getcart:1}, success:function(response){ $('#getcart').html(response);//want to ...

Despite the presence of the gecko driver, the URL that was entered is still failing to load

When the URL is loaded, only a blank page appears. This code utilizes Maven Framework and includes: Firefox version: 49.x Selenium driver version: 3.4.0 Here is the code snippet: System.setProperty("webdriver.gecko.driver","D://SW//geckodriver//geckod ...