Unable to access text field in an iframe

后端 未结 1 613
一向
一向 2021-01-16 20:05

I am trying to automate script for testing using Watir-Webdriver. While writing a script, I am at a point where I have to fill in log in details. Now would it have been in a

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-16 20:45

    In the following line, Watir will look for the element anywhere except for in iframes (and frames).

    b.text_field(:id,'lid').set 'my value'
    

    Unlike other elements, you must tell Watir when an element is in a frame. This is done similar to how you would scope the search of an element to a specific element.

    For example, if there is only 1 iframe or your element is in the first iframe, you can do (noting the addition of the .iframe):

    b.iframe.text_field(:id => 'lid').set 'my value'
    

    If there are multiple iframes, you will need to add parameters to be more specific about which iframe to use. For example, the frame has an id:

    b.iframe(:id => 'zohoiam').text_field(:id,'lid').set 'my value'
    

    0 讨论(0)
提交回复
热议问题