找不到硒汇总元素

时间:2016-12-13 04:10:38

标签: selenium rollup

我是selenium ui-element的新手,在此之前我总是选择selenium IDE。当我尝试使用rollup命令时,我在uimap.js文件中定义了一个汇总管理器:

myRollupManager.addRollupRule({
    name: 'login_in'
    , description: 'login'
    , pre: 'xxx'
    , post: 'xxx'
    , commandMatchers: []
    , expandedCommands: [
    {
        command: 'click'
        , target: 'loginbutton'
    }
    ]
});

loginbutton元素如下:

myMap.addElement('LoginPages', {
    name: 'loginbutton'
    , description: 'login button'
    , locator: "//*[@id='login-form']/*/button"  
});

但是当我在IDE中执行以下命令时:

|command|target|value|
|click|login_in||

我总是得到“找不到元素登录按钮”错误:

我尝试了很多种xpath定位器,当涉及到ide而没有汇总时,它们中的每一个都可以正常工作:

|command|target|value|
|click|//*[@id='login-form']/*/button||
|click|//xpath=//*/button||

当locator是“locator:”xpath = // * [@ id ='xxx']“”时,我也尝试了带有id属性的input元素,效果非常好,我真的无法弄清楚发生了什么。有没有人遇到过类似的问题?

1 个答案:

答案 0 :(得分:0)

target:'loginbutton'

将无效。这是一个定位器,而不是一个ui元素。更改为:

{
    command: 'click'
    , target: 'ui=LoginPages::loginbutton()'
    //'login_button' will not work.that's a locator,not an ui-element
}