Selenium 2 C# Webdriver - 为什么我无法在 IE8 中从一个输入移动到另一个输入?

发布于 2024-11-08 21:59:28 字数 1048 浏览 4 评论 0原文

我在使用 WebDriver 和 IE8 时遇到了一个奇怪的问题,我很好奇是否有人以前见过这个问题。简而言之,我有一个测试,它跨过一组输入字段,输入文本,然后单击提交按钮(其中没有一个位于

中。)它的效果非常好在 Firefox 3.6 中,如下所示:

Driver.FindElement(By.XPath(domainXpath)).SendKeys("someDomain");
Driver.FindElement(By.XPath(emailXpath)).SendKeys("someEmailAddress");
Driver.FindElement(By.XPath(passwordXpath)).Sendkeys("somePassword");


但是当我在 IE8 上运行这个时,Selenium 似乎永远不会更改字段,即使它似乎通过指定的 XPath 正确定位了它们。

起初,我认为这可能是 xpath-ing 的问题(我见过其他人也有相关问题),但我的 SendKeys 没有因任何“未找到元素”错误而失败,并且我单击的其他元素是工作正常。事实上,Selenium 能够找到此列表中的第一个字段,并将所有三个查找的所有文本转储到该字段中。

所以,然后我稍微更改了代码,如下所示:

Driver.FindElement(By.XPath(domainXpath)).SendKeys("someDomain\t");
Driver.FindElement(By.XPath(emailXpath)).SendKeys("someEmailAddress\t");
Driver.FindElement(By.XPath(passwordXpath)).Sendkeys("somePassword\t");


...瞧,文本输入正确。

就好像 IE 忽略了 Selenium 移动到下一个字段的请求,尽管该字段正在报告存在。

以前有人经历过吗?有没有什么方法可以避免为 IE 编写特殊代码,而只是将制表符附加到每个数据项?

谢谢, 格雷格.

I've run into a quirky issue with WebDriver and IE8, and I'm curious if anyone else has seen this before. In a nutshell, I have a test that steps over a set of input fields, enters text, and then clicks on a submit button (none of which are in a <form>.) It works fantastically in Firefox 3.6, like so:

Driver.FindElement(By.XPath(domainXpath)).SendKeys("someDomain");
Driver.FindElement(By.XPath(emailXpath)).SendKeys("someEmailAddress");
Driver.FindElement(By.XPath(passwordXpath)).Sendkeys("somePassword");

But when I run this against IE8, Selenium never seems to change fields, even though it appears to be locating them correctly via the specified XPath.

At first, I thought this might be a problem with xpath-ing (I've seen others with related problems), but my SendKeys isn't failing with any "element not found" errors, and other elements I'm clicking on are working fine. In fact, Selenium is able to find the first field in this list and dumps all the text for all three Finds into that field.

So, then I changed the code just slightly, like so:

Driver.FindElement(By.XPath(domainXpath)).SendKeys("someDomain\t");
Driver.FindElement(By.XPath(emailXpath)).SendKeys("someEmailAddress\t");
Driver.FindElement(By.XPath(passwordXpath)).Sendkeys("somePassword\t");

...and, Voila, the text got entered properly.

It's as if IE is ignoring Selenium's request to move to the next field, in spite of the fact that the field is reporting present.

Has anyone experienced this before? Is there some way to avoid having to write special code for IE, just to append tabs to every item of data?

Thanks,
Greg.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

·深蓝 2024-11-15 21:59:28

实际上,这个问题似乎是 IE8 和被测应用程序之间的兼容性问题(或编码错误)。我仍在整理它,很快就会有更多细节,但现在,问题似乎有了答案。

抱歉打扰了直播……[尴尬]

Actually, this problem appears to be a compatibility issue (or coding bug) between IE8 and the app under test. I'm still sorting it out, and will have more details shortly, but for now, the question seems answered.

Sorry for cluttering the stream... [embarrassed]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文