gpt4 book ai didi

java - 我无法使用 IEDriver 在 IE11 Windows 10 中找到 xpath

转载 作者:行者123 更新时间:2023-12-02 05:52:35 28 4
gpt4 key购买 nike

我正在尝试查找以下代码的 xpath。但它显示出一些错误。检查元素是:

<BUTTON title="Create Customer" class="SBCUSTMENU awbButton" id=C2_W10_V11_btnCREATE_CUSTMC onmouseout=javacript:awbImgButtonMouseOut(this); onmousedown=javacript:awbImgButtonMouseDown(this); onmouseup=javacript:awbImgButtonMouseUp(this); onclick="javascript:if(awbBtnActive(this)){if (awbAddMonitorIdsToHttp(['MONITOR_JOURNEY','','MONITOR_STEP',''])){htmlbSubmitLib('htmlb',this,'htmlb:button:click:null','myFormId','C2_W10_V11_btnCREATE_CUSTMC','onclick_CREATE_CUSTMC',0);}}return false;" type=button awbClass="awbButton SBCUSTMENU">&nbsp;</BUTTON>

driver.findElement(By.id("C2_W10_V11_btnCREATE_CUSTMC")).click();

我预计会出现以下错误

Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 10 seconds waiting for visibility of element located by By.id: C2_W10_V11_btnCREATE_CUSTMC
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'PC404441', ip: '10.27.101.9', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_192'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, ie.enableFullPageScreenshot=true, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.forceShellWindowsApi=false, pageLoadStrategy=normal, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:10768/, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss}]

最佳答案

如果您单击的元素是动态生成的,您可能需要引发 WebDriverWait:

import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;

(new WebDriverWait(driver, 10)).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[title='Create Customer']")).click();

关于java - 我无法使用 IEDriver 在 IE11 Windows 10 中找到 xpath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56037767/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com