【问题标题】:Tosca puzzle 41040 solved with RBFW: can't click the button托斯卡谜题 41040 用 RBFW 解决:无法点击按钮
【发布时间】:2021-11-21 09:32:29
【问题描述】:

非常困在这个谜题中:

来源页面为:https://obstaclecourse.tricentis.com/Obstacles/41040

到目前为止我尝试的是:

*** Settings ***
Library    Browser
#Library    String
# title = CLICK ME IF YOU CAN

*** Variables ***

*** Test Cases ***
Example Test 70310
    OPEN BROWSER  https://obstaclecourse.tricentis.com/Obstacles/41040
    #${txt}=    GET TEXT    //span[contains(text(),'Table contains')]
    #CLICK    //*[contains(text(),'Click me if you can')][1]
    #
    #CLICK        //*[contains(text(),'Click me if you can')][1]  delay=100ms     clickCount=2
    #CLICK    id=buttonclick
    CLICK       xpath=//input[@id='buttontoclick']      clickCount=2
    MOUSE BUTTON    left    
    #//div[@id='']//div[@id='']
    #//div[@id='']//*[contains(text(),'Click me if you can')]
    Get Text         xpath=//body    *=   You solved this automation problem.
    # used resources  (usefull)  https://forum.katalon.com/t/two-objects-have-same-xpath/8713

FlurFunk 有一个使用 Tosca 的解决方案,可以在这里找到: https://www.youtube.com/watch?v=cdNRfvp_qHU

我还没有找到使用 RBFW 的解决方案,并且对所有尝试感到有点恼火。 这里的代码问题是:如何找到唯一元素?

【问题讨论】:

  • 好吧,定位器是//input[@value='Click me if you can'] - 但这不足以解决它 - js 将鼠标移到元素上,这就是正常的 click() 所做的。
  • 完全正确。所以我们需要另一种方式。可以在 Tosca 完成,我相信 RBFW 也可以完成,问题是“如何”?

标签: robotframework puzzle tosca


【解决方案1】:

知道了!!!终于

 ${ele}    Get WebElement    //input[@id='buttontoclick']
    Execute Javascript    arguments[0].click();     ARGUMENTS    ${ele} 
    ELEMENT TEXT SHOULD BE    xpath=//body    You solved this automation problem.
   

    # (notice the last comment on the following page: )
    # used resources  https://stackoverflow.com/questions/48181988/robot-framework-click-element-using-execute-javascript
    # used resources  https://www.youtube.com/watch?v=1isRH9E9WAE  ;)

【讨论】:

  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
  • A javascript click() 并不是普通用户会做的事情,还有另一种更接近正常使用模式的解决方案 (哎呀,普通乔不知道有控制台,或者js 是什么,或者针对外部找到的 DOM 对象是什么)。请记住,自动化应该模仿手动流程,即用户期望手动执行的操作。
猜你喜欢
  • 2021-11-17
  • 2013-11-29
  • 2021-11-21
  • 2012-06-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多