最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Frame handling in Webdriver IO - Stack Overflow

programmeradmin7浏览0评论

I am testing a webpage that has multiple forms in it.

When I use

client.frame({id:client.element('#frameId')});

I don't get any error, but when I try to interact with an element within that frame I get a RuntimeError telling me the element could not be located.

I have been looking out for literature about how the frame() method works but I don't have any luck.

I am testing a webpage that has multiple forms in it.

When I use

client.frame({id:client.element('#frameId')});

I don't get any error, but when I try to interact with an element within that frame I get a RuntimeError telling me the element could not be located.

I have been looking out for literature about how the frame() method works but I don't have any luck.

Share Improve this question asked May 6, 2015 at 15:54 AbhinavAbhinav 1,0422 gold badges12 silver badges26 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 4

I was also using webdriver.io and it looks like documentation is a bit wrong.

You can access frames:

1) via it's number on the page. For example the first frame met in HTML DOM is client.frame(0), second client.frame(1) etc

2) via name attribute: <frame name="test"></frame> client.frame('test')

3) find the element with client.element('css_selector'), then in a callback pass the returned value to the .frame()

The way to go to a new frame is:

client.frame(<id of frame here>)

What you have should work too though. Try doing a client.waitForExist on an element that only exists on the frame, instead of just switching to frame and immediately trying to interact with element in that frame, as you may be firing your interaction event before selenium has had a chance to fully switch to the frame:

client.frame(<id of frame here>
client.waitForExist(<id of some css element that only exists in the frame>)

client.frame(<name_of_frame>) worked.

I tried using a selector like #idOfSelector but it didn't seem to work.

This works for me

const frameValue = browser.element('frame_selector').value;
browser.frame(frameValue);

Hopefully, it works for you.

发布评论

评论列表(0)

  1. 暂无评论