将 WatiN 与 rad 菜单项一起使用大多数时候找不到子链接
我的测试需要单击 rad 工具菜单中的链接,但有时只能找到该链接。即使找到链接 ByText,它也无法双击它。如果我将鼠标悬停在菜单项上,它总会找到它。无法在 Watin 中找到悬停,否则我尝试过刷新、睡眠、焦点、按键、WaitUntilExists、双击等。它使用 rad 工具中的 rmText 类。
我发现唯一有效的方法是在测试运行时将鼠标悬停在下拉菜单上...... 希望我可以这样做几秒钟...
//process 将是 radtool 菜单项下方的一个菜单项,仅在存在某些条件时才显示(但总是在悬停时显示)
if (ie.Link(Find. ByText("process")).Exists) //有时我会通过这里 ie.Link(Find.ByText("进程")).Click(); // 仅当我悬停时才有效
My test needs to click a link from a rad tools menu that it can only find some of the time. Even when it finds the link ByText it cannot double click it. If I hover the menu item it will always find it. Cannot find a hover in Watin, otherwise I've tried refresh, sleeps, focus, keypress, WaitUntilExists, double clicks, etc. Its using a class rmText from rad tools.
The only thing I've found to work is hovering that drop down while the tests are running...
Wish I could just do that for a few seconds...
//process would be a menu item below the radtool menu item that only shows up when certain conditions exist (but always does with the hover)
if (ie.Link(Find.ByText("process")).Exists) //sometimes I get through here
ie.Link(Find.ByText("process")).Click(); // this works only if I hover
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建菜单项可能需要一些时间。调用 Exists 确实会检查它现在是否存在,也许如果您等待几(毫秒)它就会在那里。尝试调用
ie.Link(Find.ByText("process")).WaitUntilExists()
如果元素从未出现,这将超时,否则您可以保存调用单击。
顺便说一句,也许你可以摆脱存在检查,WatiN 在调用 Click() 之前也会自行调用 WaitUntilExists。
哈特哈,
杰罗恩
Might be that creating the menu item is taking some time. Calling Exists does check if it exists now, maybe if you wait a few (milli)seconds it will be there. Try calling
ie.Link(Find.ByText("process")).WaitUntilExists()
This will time out if the element never appears, otherwise you can savely call the click.
BTW maybe you can get rid of the exists check, WatiN does call WaitUntilExists by itself too before calling Click().
HTH,
Jeroen