简体   繁体   English

JMeter Groovy - WebDriver Sampler 脚本失败,响应代码为 500

[英]JMeter Groovy - WebDriver Sampler script failed with Response Code 500

I am not sure why keep failed with Response Code 500 on my script.我不确定为什么在我的脚本上保持失败,响应代码为 500。 Please is my sample code and error messages.请是我的示例代码和错误消息。 Please kindly advise.请多多指教。 Many thanks.非常感谢。

Error Messages:错误信息:

timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
1612415604534,36638,jp@gc - WebDriver Sampler,500,"javax.script.ScriptException: org.openqa.selenium.ElementNotInteractableException: element not interactable
(Session info: chrome=88.0.4324.146)

Sample Code:示例代码:

import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.*;
WDS.sampleResult.sampleStart();
WDS.browser.get("https://uat-testing.com/");
sleep(10000);
WDS.browser.findElement(org.openqa.selenium.By.xpath("//input[@type='text']")).sendKeys("xxxx@testing.com");
WDS.browser.findElement(org.openqa.selenium.By.xpath("//input[@type='password']")).clear();
WDS.browser.findElement(org.openqa.selenium.By.xpath("//input[@type='password']")).sendKeys("xxx@xxxx");
WDS.browser.findElement(org.openqa.selenium.By.xpath("//button/span")).click();
sleep(20000);
WDS.browser.findElement(org.openqa.selenium.By.xpath("//div[10]/li/span")).click();
WDS.browser.findElement(org.openqa.selenium.By.xpath("//div[16]/li/span")).click();
WDS.browser.findElement(org.openqa.selenium.By.xpath("//div[3]/li/span")).click();
WDS.browser.findElement(org.openqa.selenium.By.xpath("//div[5]/div/div/div")).click();
WDS.browser.findElement(org.openqa.selenium.By.xpath("//ul[contains(@id,'dropdown-menu-')]/li")).click();
WDS.browser.findElement(org.openqa.selenium.By.xpath("(//button[contains(@type,'button')])")).click();
sleep(30000);
WDS.sampleResult.sampleEnd();

This ElementNotInteractableException means that the element you're trying to work with cannot be used by WebDriverElementNotInteractableException意味着您尝试使用的元素不能被 WebDriver 使用

Thrown to indicate that although an element is present on the DOM, it is not in a state that can be interacted with.抛出表示虽然元素存在于 DOM 中,但它不在可与之交互的 state 中。

Most probably it's "covered" by other DOM element so the options are in:很可能它被其他 DOM 元素“覆盖”,因此选项位于:

  • Use Explicit Wait for "waiting" until the element can be accessed (by the way you should also consider replacing your "sleeps" with the explicit waits as it's kind of a performance anti-pattern)使用显式等待“等待”直到可以访问元素(顺便说一下,您还应该考虑用显式等待替换“睡眠”,因为它是一种性能反模式)
  • Instead of trying to work with particular this element you might want to interact with the one which hovers it, to wit change locator to another one而不是尝试使用特定的这个元素,您可能希望与悬停它的元素进行交互,以将定位器更改为另一个
  • And finally you can use JavaScript Executor in order to perform the "click" by means of JavaScript最后,您可以使用JavaScript 执行程序以通过 JavaScript 执行“点击”

More information on WebDriver Sampler: The WebDriver Sampler: Your Top 10 Questions Answered有关 WebDriver Sampler 的更多信息: WebDriver Sampler:您回答的 10 大问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM