0
votes

I am trying to execute selenium commands through jmeter. I am getting the following error: **

ERROR c.g.j.p.w.s.WebDriverSampler: invalid selector: Unable to locate an element with the xpath expression ChromeDriver: chrome on WINDOWS (7a2e8c66b4fbd3c2a78cc3ea8c9cb449) because of the following error:
NamespaceError: Failed to execute 'evaluate' on 'Document': The string 'ChromeDriver: chrome on WINDOWS (7a2e8c66b4fbd3c2a78cc3ea8c9cb449)' contains unresolvable namespaces.
  (Session info: chrome=80.0.3987.106)*

*

Steps I have done:

  1. Install Jmeter, download libraries, Install ChromeWebDriver
  2. Assigned the path of chromewebriver to Path in jp@gc - Chrome Driver Config Element
  3. Imported necessary libraries in web Driver sampler

Attaching a screenshot of my WebDriver sampler:enter image description here

Can anyone help please?

1
looks like you are using "pkg" as if it were a driver instance. - pcalkins

1 Answers

0
votes

C'mon, you're trying to locate the element using ChromeDriver: chrome on WINDOWS (7a2e8c66b4fbd3c2a78cc3ea8c9cb449) line which is not a valid XPath expression to me so most probably you want to use something else, not ${Browser} as the XPath query.

First of all try hard-coding the necessary XPath expression into your script like:

var browser_button=WDS.browser.findElement(pkg.By.xpath('//button[text()='Some text')]'))

and once it will be successful you can substitute it with a JMeter Variable of your choice.

A couple more hints:

  1. Don't refer JMeter Variables as ${Browser}, use WDS.vars shorthand instead like:

    var myVar = WDS.vars.get('myVar')
    
  2. Don't use Thread.sleep(), it's a performance antipattern, consider using explicit wait instead

More information: The WebDriver Sampler: Your Top 10 Questions Answered