如何解决org.openqa.selenium.WebDriverException? [英] How to resolve org.openqa.selenium.WebDriverException?

查看:167
本文介绍了如何解决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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆