【问题标题】:Select radio button with robotframework选择带有机器人框架的单选按钮
【发布时间】:2017-06-25 18:36:50
【问题描述】:

我正在尝试使用Robotframework(Python2.7,Selenium2Library) 选择一个单选按钮。

我有以下代码:

<div id="dt_method_cashondelivery" class="u-border-b-dotted u-space-pt-10                                                       
 u-space-pb-5">
     <input id="p_method_cashondelivery" class="Form-check-toggle"  
 type="radio"title="Cash On Delivery" name="payment[method]"           
 value="cashondelivery"/>
     <label class="Form-radio" for="p_method_cashondelivery">
         <span>Cash On Delivery </span>
     </label>
 </div>

我使用的机器人框架代码是:

Select Radio Button    payment[method]    cashondelivery

有什么想法吗?

【问题讨论】:

  • 明确说明问题。你有什么错误吗?
  • 你用什么代码来点击单选按钮?
  • 我使用了带有参数 groupname=payment[method] 和 value=cashondelivery 的选择单选按钮。
  • 我收到以下错误:ValueError: Element locator 'xpath=//input[@type='radio' and @name='payment[method]' and (@value='cashondelivery' or @id='cashondelivery')]' 没有匹配任何元素。
  • 好的,我会和我的开发团队谈谈,看看我们是否可以修改代码中的某些内容。无论如何,非常感谢你的帮助。祝你有美好的一天。

标签: python-2.7 radio-button automated-tests robotframework


【解决方案1】:

使用下面的关键字

Click Element    jquery=#p_method_cashondelivery

Click Element    css=#p_method_cashondelivery

如果您使用 id 属性定位元素,则在其前面加上 '#',如果您使用 class 定位元素,则在其前面加上'.'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-01
    • 2020-10-07
    • 2018-07-15
    • 2012-04-24
    • 2019-03-16
    • 2014-07-31
    • 1970-01-01
    • 2014-09-15
    相关资源
    最近更新 更多