我正在Selenium java中尝试此代码,以便在CRM中添加实体,但由于出现以下错误而无法这样做。
**no such element: Unable to locate element: {"method":"xpath","selector":"//div[@class='fis-tabs-bar']//button"}
(Session info: chrome=72.0.3626.119)
(Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:05:20.749Z'
System info: host: 'AP-BGLR-LP0407', ip: '10.253.210.16', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_181'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.41.578737 (49da6702b16031..., userDataDir: C:\Users\e5406216\AppData\L...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:53667}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 72.0.3626.119, webStorageEnabled: true}
Session ID: d4da17fb0a2f110d6d998158cd228948
*** Element info: {Using=xpath, value=//div[@class='fis-tabs-bar']//button}**
请看一下这段代码。
有人可以帮我吗?
@Test
public void addIndividual() throws Exception
{
WebDriverWait wait=new WebDriverWait(driver, 500);
try
{
driver.findElement(By.xpath("//div[@class='fis-tabs-bar']//button")).click();
driver.findElement(By.xpath("//div[text()="Contacts"]")).click();
driver.findElement(By.xpath("//a[text()="Add Individual"]")).click();
AddIndividualPage=wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()=\"Add Individual\"]")));
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}