Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Selenium中运行相同脚本时的不同输出_Selenium - Fatal编程技术网

在Selenium中运行相同脚本时的不同输出

在Selenium中运行相同脚本时的不同输出,selenium,Selenium,同样的脚本偶尔会给我一些异常(NoSuchElementException) 或 element单击InterceptedException)大部分时间运行正常。原因可能是什么 public static void yesNoDropDown(WebElement x, WebElement y){ WebDriverWait wait = new WebDriverWait(driver, 10); WebElement element = wait.until(Expecte

同样的脚本偶尔会给我一些
异常(NoSuchElementException)

element单击InterceptedException)
大部分时间运行正常。原因可能是什么

public static void yesNoDropDown(WebElement x, WebElement y){
    WebDriverWait wait = new WebDriverWait(driver, 10);
    WebElement element = wait.until(ExpectedConditions.elementToBeClickable(x));

    Actions actions = new Actions(driver);
    actions.moveToElement(element).click().perform();

    WebElement element2 = wait.until(ExpectedConditions.elementToBeClickable(y));

    element2.click();

这里没有足够的信息,但似乎是由于超时(在达到预期条件前10秒)。click intercepted异常将告诉您是什么元素导致了该特定异常。。。通常,当一个bug看起来是随机的时,它通常是由于时间问题或内存泄漏造成的。对于相同或不同的元素,您是否看到
NoTouchElementException
element单击InterceptedException
?如何确定WebElement x和y?你在用PageFactory吗?相反,尝试在此处传递变量,等待它们并单击。第一个元素通常获取ElementClickInterceptedExeption,第二个元素为NoTouchElementExeption。我确实使用PageFactory,但我尝试直接传递veritable-相同的输出。