0

I use Apache JMeter 5.4.1 and chromedriver 107.0.5304.62 for web page access test. If I execute the test scenario without headless mode, and it succeeds. But when the headless mode is enabled, the test failed and following error occurs. enter image description here

2022-11-16 09:21:45,271 ERROR c.g.j.p.w.s.WebDriverSampler: Expected condition failed: waiting for element to be clickable: By.xpath: //*[@id="sub"]/ul/li[5]/a (tried for 120 second(s) with 500 milliseconds interval) Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z' System info: host: 'EC2AMAZ-HQV0HF4', ip: '192.100.1.13', os.name: 'Windows Server 2019', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_351' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 107.0.5304.107, chrome: {chromedriverVersion: 107.0.5304.62 (1eec40d3a576..., userDataDir: C:\Users\DAISKA~1\AppData\L...}, goog:chromeOptions: {debuggerAddress: localhost:50048}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(direct), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true} Session ID: dbe1607372464587370fb424398e501b

I changed the scenario(increased the wait time), but nothing changed. The scenario is following.

var pkg = JavaImporter(org.openqa.selenium, org.openqa.selenium.support.ui) var wait = new pkg.WebDriverWait(WDS.browser, 120) wait.until(pkg.ExpectedConditions.elementToBeClickable(pkg.By.xpath('//[@id="sub"]/ul/li[5]/a'))) var activity = WDS.browser.findElement(pkg.By.xpath('//[@id="sub"]/ul/li[5]/a')) activity.click()

eng
  • 15
  • 1

1 Answers1

0
  1. Get the page source and inspect whether the element is there

  2. Take the screenshot and check whether the element you're looking for is there.

  3. It might be the case you need to increase the resolution of the headless browser, something like:

    enter image description here

  4. It might be the case the website you're testing behaves differently if it detects that you're using a headless browser

  5. There is a DRY principle so instead of waiting/finding/clicking you can use just one line which combines all actions:

    wait.until(pkg.ExpectedConditions.elementToBeClickable(pkg.By.xpath('//[@id="sub"]/ul/li[5]/a'))).click()
    
  6. Since JMeter 3.1 it's recommended to use Groovy for scripting mainly because Groovy provides maximum performance comparing to other scripting engines. Moreover JavaScript has been removed in Java 15 so you can face problems when you migrate to the most recent Java version.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • I set "--window-size=1920,1080" to Additional arguments, and the test worked well. Thank you for your advice. – eng Nov 21 '22 at 12:54