当元素的CSS仅包含ID时,我无法单击按钮/元素

时间:2019-03-18 15:02:07

标签: selenium selenium-webdriver frameworks robotframework

我正在尝试使用Robot Framework-Selenium单击一个按钮。 按钮的元素如下所示:

<div id="isc_7A" eventproxy="addButton" onfocus="isc.EH.focusInCanvas(addButton_label,true);" onblur="if(window.isc)isc.EH.blurFocusCanvas(addButton_label,true);" tabindex="-1" style="position: absolute; left: 6px; top: 1px; width: 65px; height: 22px; z-index: 201603; overflow: visible; cursor: pointer;" onscroll="return addButton.$lh()">
    <div id="isc_79" eventproxy="addButton" style="position: relative; visibility: inherit; z-index: 201603; cursor: pointer;">
        <table cellspacing="0" cellpadding="0" width="1" height="22">
            <tbody>
                <tr>
                    <td nowrap="true" class="stretchImgButton" align="center" valign="center" tabindex="-1" onfocus="addButton_label.$47()">
                        <table cellspacing="0" cellpadding="0">
                            <tbody>
                                <tr>
                                    <td class="stretchImgButton" style="margin:0px;border:0px;padding:0px;background-image:none;background-color:transparent;-webkit-box-shadow:none;box-shadow:none;font-size:1px;padding-right:6px"><img src="https://hq-foxtrot-s1.hq-foxtrot.defencetest.local:10006/journal/images/tag_new.png" width="16" height="16" align="absmiddle" name="isc_79addButton_label$4u" style="vertical-align:middle" eventpart="icon" border="0" suppress="TRUE"></td>
                                    <td class="stretchImgButton" style="margin:0px;border:0px;padding:0px;background-image:none;background-color:transparent;-webkit-box-shadow:none;box-shadow:none;" nowrap="true">New Tag</td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

我在PyCharm中的测试如下:

*** Settings ***
Documentation  Create a new tag
Library  SeleniumLibrary

*** Test Cases ***
This is some basic info about the test
    [Documentation]  This is some basic info about the test
    [Tags]  Smoke
    Open Browser  [website]  chrome
    Sleep  10sec
    wait until page contains element  css=#isc_7A
    click button  css=#isc_7A

我也尝试过使用元素的xpath,但仍然没有成功。 xpath看起来像这样:

//*[@id="isc_7A"]

0 个答案:

没有答案