无法单击页面左侧面板内的字段

时间:2017-02-07 11:00:41

标签: selenium selenium-webdriver

我已经尝试过以下代码来点击这些字段,但会收到错误

 "org.openqa.selenium.WeddriverException:unknown error: Element is not clickable at point(138,353). Other element would receive the the click… display: block;>…."

代码:

WebElement el1 = driver.findElement(By.xapth(".//*@id='BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));
         JavascriptExecutor executor = (JavascriptExecutor)driver;
         executor.executeScript("arguments[0].click()", el1);

UI: 参考附件截图 enter image description here

HTML code:

<div id="datatab" class="dijitContentPane panel-content dijitStackContainer-child dijitStackContainer-dijitContentPane" style="padding: 0px; overflow: hidden; left: 0px; top: 0px; height: 154px; width: 258px;" selected="true" data-dojo-type="dijit.layout.ContentPane" widgetid="datatab" title="">
    <div id="datatabpanel" class="tabpanel" style="height: 100%; overflow:hidden; padding: 0px">
        <div class="section-header-outer">
            <div id="fieldlistContainer" style="height: 0px;">
                <div id="fieldlist" class="dojoDndSource dojoDndContainer" data-dojo-attach-point="containerNode" widgetid="fieldlist">
                    <div id="category11545">
                        <div id="field-BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID" class="category11545 field treenode-leaf-label pentaho-listitem dojoDndItem" fieldid="BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID" title="BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID">Patient ID</div>

3 个答案:

答案 0 :(得分:0)

您不能单击div元素,而是可以使用变通方法通过对同一元素执行“ dragAndDrop操作 ”来触发点击事件。 / p>

答案 1 :(得分:0)

尝试以下代码:

new WebDriverWait(driver, 10).until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//div[@style='position: absolute; left: 0px; top: 88px; width: 1366px; height: 677px; display: block;']")));
WebElement el1 = driver.findElement(By.xpath(".//*[@id='field-BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));
     JavascriptExecutor executor = (JavascriptExecutor)driver;
     executor.executeScript("arguments[0].click()", el1);

答案 2 :(得分:0)

您附加的html没有id属性,其值为BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID。你能改变你的xpath -

吗?
WebElement el1 = driver.findElement(By.xapth(".//*@id='BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));

WebElement el1 = driver.findElement(By.xapth(".//*[@fieldid='BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));

//or

WebElement el1 = driver.findElement(By.xapth(".//*[@id='field-BC_PATIENT_COMMUNITY_ENROLLMENT_PATIENT_ID']"));