如何在aspeciafic元素

时间:2018-06-12 06:05:40

标签: python splinter

我正在尝试为项目编写测试自动化代码。但是我无法为位于HTML页面中的元素设置XPath。

这是代码

<div class="info-container">
    <div id="div_2" class="btn-group user-helper-dropdown">
        <i  class="material-icons" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">keyboard_arrow_down</i>
        <ul id="div_3" class="dropdown-menu pull-right">
            <li><a href="/profile/user/view"><i class="material-icons">person</i>Profile</a></li>
            <li role="seperator" class="divider"></li>
            <li id="sgn_out"><a id="sign_out_button" href="/sign-out"><i class="material-icons">input</i>Sign Out</a></li>
        </ul>
    </div>
</div>

我想为包含<a> id的{​​{1}}设置XPath。

以下是我为测试自动化编写的代码

"sign_out_button"

当我运行代码它给了我这个错误

  

追踪(最近一次通话):         文件“C:/Users/ChampsoftWK26/Desktop/Projects/Jericho/Jericho_v0.0.7/test/SplinterTest.py”,第16行,in           browser.find_by_xpath( '// * [@ ID = “sign_out_button”]')。单击()         文件“C:\ Users \ ChampsoftWK26 \ Envs \ jerich_core \ lib \ site-packages \ splinter \ driver \ webdriver__init __。py”,第562行,点击           self._element.click()         文件“C:\ Users \ ChampsoftWK26 \ Envs \ jerich_core \ lib \ site-packages \ selenium \ webdriver \ remote \ webelement.py”,第80行,点击           self._execute(Command.CLICK_ELEMENT)         文件“C:\ Users \ ChampsoftWK26 \ Envs \ jerich_core \ lib \ site-packages \ selenium \ webdriver \ remote \ webelement.py”,第628行,在_execute中           return self._parent.execute(command,params)         文件“C:\ Users \ ChampsoftWK26 \ Envs \ jerich_core \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py”,第314行,执行           self.error_handler.check_response(响应)         文件“C:\ Users \ ChampsoftWK26 \ Envs \ jerich_core \ lib \ site-packages \ selenium \ webdriver \ remote \ errorhandler.py”,第242行,在check_response中           提出exception_class(消息,屏幕,堆栈跟踪)       selenium.common.exceptions.ElementNotVisibleException:消息:元素不可见         (会话信息:chrome = 67.0.3396.79)         (驱动信息:chromedriver = 2.39.562718(9a2698cba08cf5a471a29d30c8b3e12becabb0e9),platform = Windows NT 10.0.17134 x86_64)

0 个答案:

没有答案