Java Selenium有时找不到元素

Java Selenium有时找不到元素,java,selenium,Java,Selenium,我使用Selenium与Jira互动。我的应用程序从谷歌工作表中读取时间日志,并将其插入Jira时间记录器(非标准Jira插件) 问题是,当我尝试单击TimeLog插件时,Selenium会在后台不时返回以下exeption(其他后台正常工作) 我可以运行应用程序的前10-15次,它工作正常,然后我看到这样一个异常。 当我手动关闭打开的驱动程序(通过任务管理器)并清理Windows和Chrome临时文件时,可能会给我更多的时间来运行应用程序。然后我收到同样的异常 我尝试使用不同的驱动程序(MS-

我使用Selenium与Jira互动。我的应用程序从谷歌工作表中读取时间日志,并将其插入Jira时间记录器(非标准Jira插件)

问题是,当我尝试单击TimeLog插件时,Selenium会在后台不时返回以下exeption(其他后台正常工作)

我可以运行应用程序的前10-15次,它工作正常,然后我看到这样一个异常。 当我手动关闭打开的驱动程序(通过任务管理器)并清理Windows和Chrome临时文件时,可能会给我更多的时间来运行应用程序。然后我收到同样的异常

我尝试使用不同的
驱动程序(MS-Edge),检查相对
xPath
,使用不同的
等待
策略

public void runSelenium(WebDriver驱动程序)抛出InterruptedException、IOException、GeneralSecurityException{
如果(!driver.getTitle().equals(“Google”)){
driver.manage().window().maximize();
}
输入登录(驱动程序);
《睡眠》(2000年);
输入密码(司机);
睡眠(7000);
openProject(驱动程序);
睡眠(3000);
公开发行(驱动程序);
睡眠(5000);
//以上各阶段工作正常
if(isNewLogsToInput()){
输入新日志(驱动程序);
}
}
私有void inputNewLogs(WebDriver驱动程序)引发InterruptedException、IOException、GeneralSecurityException{
int entriesNumber=reader.getEntriesNumberFromSheets();
int numberOfNewLogs=entriesNumber-logs.getTimeLogsQuantity();
int startPosition=entriesNumber-新日志数;
对于(int i=起始位置;i
private void openTimeLog(WebDriver驱动程序){
WebDriverWait wait=新的WebDriverWait(驱动程序,20);
WebElement button=等待.until(ExpectedConditions.visibilityOfElementLocated(
第二个国家/div[2]1/div[2]1/div[2]1/div[2]1/div[1/div[1]1/div[1/div[1]1/div[1/div[1]1/div[2]1/div[1]1/div[1]1/1/2]1/1/1/1/1/1/1/1/1/1/1/1/1/1/div[1/div[1]1/1/div[1/div[1]1/1/1/div[1]1/1/1/1/1/1/div[1/1/div[1]1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/div[1/1/1/1/1/1/1/1 2]/小[1]”);
按钮。单击();
}


时间跟踪
时间跟踪
2d 25米测井,剩余2d
受让人
受让人
测试
标签
标签
没有一个
冲刺
Exception in thread "main" org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.xpath: //div[@class='sc-bvODop kOWqZw' and @xpath='1'] (tried for 40 second(s) with 500 milliseconds interval)
    at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:95)
    at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:272)
    at com.fox.jiratimelog.selenium.SeleniumOperator.openTimeLog(SeleniumOperator.java:143)
    at com.fox.jiratimelog.selenium.SeleniumOperator.inputNewLogs(SeleniumOperator.java:60)
    at com.fox.jiratimelog.selenium.SeleniumOperator.runSelenium(SeleniumOperator.java:50)
    at com.fox.jiratimelog.JiraTimeLogApplication.main(JiraTimeLogApplication.java:24)
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@class='sc-bvODop kOWqZw' and @xpath='1']"}
  (Session info: chrome=86.0.4240.75)
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-OFG72V5', ip: '192.168.0.105', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '14.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 86.0.4240.75, chrome: {chromedriverVersion: 85.0.4183.87 (cd6713ebf92fa..., userDataDir: C:\Users\Max\AppData\Local\...}, goog:chromeOptions: {debuggerAddress: localhost:49319}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Session ID: e3a81681e9e6873351bab1211c3386e7
*** Element info: {Using=xpath, value=//div[@class='sc-bvODop kOWqZw' and @xpath='1']}
    at jdk.internal.reflect.GeneratedConstructorAccessor21.newInstance(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428)
    at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
    at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:205)
    at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:201)
    at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:249)
    ... 4 more
By.cssSelector("div[class*='Content__ChildWrapper'] small")