如何解决org.openqa.selenium.WebDriverException?

编程入门 行业动态 更新时间:2024-10-20 08:31:09
本文介绍了如何解决org.openqa.selenium.WebDriverException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在编写一个自动化测试,并要在GitHub的存储库中直接报告错误(如果发生).在我的程序中失败的步骤是GitHub Issue Tracker中的提交新问题按钮.

I am writing an automated test and want to report bugs, if occur, directly in the repo at GitHub. The step which fails in my program is the Submit new issue button from GitHub Issue Tracker.

这是代码:

WebElement sendIssue = driver.findElement(By.xpath("/html/body/div[5]/div/div/div[2]/div[1]/div/form/div[2]/div[1]/div/div/div[3]/button")); sendIssue.click();

还有一个例外:

org.openqa.selenium.WebDriverException:无法在以下位置单击元素 点(883,547.7999877929688).其他元素将获得点击: div class ="modal-backdrop">

org.openqa.selenium.WebDriverException: Element is not clickable at point (883, 547.7999877929688). Other element would receive the click: div class="modal-backdrop">

以下命令也不起作用:

((JavascriptExecutor) driver).executeScript("arguments[0].click();", sendIssue);

如何使其可点击?还有其他方法可以解决此问题吗?

How can I make it clickable? Is there any other way by which I can resolve this issue?

在此处输入图像描述

推荐答案

之所以发生这种情况,是因为当硒试图单击时,所需的元素不可单击.

This is happening because when selenium is trying to click ,the desired element is not clickable.

必须确保您提供的Xpath绝对正确.如果您确定Xpath正确,请尝试以下操作

You have to make sure that the Xpath provided by you is absolutely right.If you are sure about the Xpath then try the following

替换

WebElement sendIssue = driver.findElement(By.xpath("/html/body/div[5]/div/div/div[2]/div[1]/div/form/div[2]/div[1]/div/div/div[3]/button")); sendIssue.click();

WebElement sendIssue =(WebElement)new WebDriverWait(DRIVER,10).until(ExpectedConditions.elementToBeClickable(By.xpath("/html/body/div[5]/div/div/div[2]/div[1]/div/form/div[2]/div[1]/div/div/div[3]/button"))); sendIssue.click();

如果这不起作用,您将收到一个Timeout异常,在这种情况下,请尝试将超时量从10减少到20.

If that doesn't work ,You will get an Timeout exception, In that case try incaresing the timeout amount from 10 to 20.

如果仍然无法正常运行,请发布HTML的屏幕截图.

If it still doesn't work please post a screenshot of the HTML.

您需要在问题标题和描述中写一些内容,以使问题可单击,如果您确定在没有添加任何内容的情况下没有单击按钮的错误,我将在此处添加屏幕截图以方便您.

You need to write something in the issue title and description to make the issue clickable are you sure you are not making that mistake of clicking the button without writing anything in those places I am adding screenshot for your convenience.

更多推荐

如何解决org.openqa.selenium.WebDriverException?

本文发布于:2023-10-25 08:42:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1526464.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何解决   org   openqa   selenium   WebDriverException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!