Python 无法修复:AttributeError:StartWith
我正在尝试使用robot framework运行一些测试,ann我想在某些元素可见后执行一些操作: 这就是我所尝试的:Python 无法修复:AttributeError:StartWith,python,selenium,pycharm,robotframework,Python,Selenium,Pycharm,Robotframework,我正在尝试使用robot framework运行一些测试,ann我想在某些元素可见后执行一些操作: 这就是我所尝试的: Page Should Contain Element ${TRAIN_LABEL} element should be visible ${TRAIN_LABEL} Wait Until Keyword Succeeds ${RETRY_TIMEOUT} ${RETRY_INTERVAL} Wait Until Element is Visible $
Page Should Contain Element ${TRAIN_LABEL}
element should be visible ${TRAIN_LABEL}
Wait Until Keyword Succeeds ${RETRY_TIMEOUT} ${RETRY_INTERVAL} Wait Until Element is Visible ${TRAIN_LABEL}
我的列车标签变量:
${TRAIN_LABEL}=xpath=/*[@id='trainHeader'并包含(@data TRAIN id,'548')]
但当我运行测试时,它会给我:
AttributeError:StartWith
错误
我怎样才能解决这个问题
html:
测试存在/停止于:
Page Should Contain Element ${TRAIN_LABEL}
或
或
这三个关键字都不起作用,信息有限,但我将尝试: 您定义了
${TRAIN\u LABEL}=xpath=/*[@id='trainHeader'并包含(@data TRAIN id,'548')]
如果上述内容位于变量部分,则在${TRAIN\u LABEL}
后面的可选=
符号后应至少有2个空格。如果它不在变量部分,则不能这样赋值。您需要使用设置变量
关键字:
${TRAIN_LABEL} Set Variable xpath=//*[@id='trainHeader'and contains(@data-train-id,'548')]
你能发布html页面源代码吗?@Sureshmani我不能发布整个html,但我用我要测试的元素的html代码更新了帖子,哪个关键字会给你这个错误?@BryanOakley${TRAIN_LABEL}@BryanOakley我分别尝试了上面这些关键字以达到同样的效果,问题似乎出在变量中
Page Should Contain Element ${TRAIN_LABEL}
Element Should Be Visible ${TRAIN_LABEL}
Wait Until Keyword Succeeds ${RETRY_TIMEOUT} ${RETRY_INTERVAL} Wait Until Element is Visible ${TRAIN_LABEL}
${TRAIN_LABEL} Set Variable xpath=//*[@id='trainHeader'and contains(@data-train-id,'548')]