FireFox无法将密钥发送到日期选择器 [英] FireFox cannot sendkeys to date picker

查看:59
本文介绍了FireFox无法将密钥发送到日期选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Firefox中运行自动化测试时遇到问题。我正在使用Selenium Webdriver C#。这段代码可以在Chrome上完美运行,但是在Firefox中运行 sendkeys 函数就无法正常工作。以下是元素的详细信息:

I'm Having an issue when running automation tests in Firefox. I'm using selenium webdriver c#. This code runs perfectly on Chrome but when run in Firefox the sendkeys function just doesn't work. Below is the element details:

在Firefox 58中进行测试:

Tests in Firefox version 58:

<input
   id="uiAssessmentsDueDate"
   class="form-control ng-pristine ng-valid ng-empty ng-touched"
   ng-model="workshop.assessmentsDueDate"
   ng-readonly="isReadonly"
   tabindex="6"
   type="date">

这是我正在使用的代码:

Here is the code I'm using:

Driver.FindElement(By.Id("uiAssessmentsDueDate")).SendKeys("01012018");

我尝试单击该框,然后再尝试先单击该框然后发送密钥。我已经尝试了所有我能想到的。如果有人能更好地做到这一点,或者对为什么它在Firefox中不起作用的答案,将不胜感激。如果您需要更多信息,请告诉我

I have tried clicking in the box before it I have tried tabbing into the box first then send keys. I have tried everything i can think of. If anyone has a better way to do this or an answer as to why this doesn't work in Firefox it would be much appreciated. If you need anymore info please let me know

推荐答案

我注意到的第一件事-有一个 ng- readonly = isReadonly 属性。只读输入不允许用户与它们进行交互,但是由于我从未使用过Angular,因此无法确定它在实际站点中的工作方式。

First thing I noticed - there is a ng-readonly="isReadonly" attribute. Read Only inputs do not allow the user to interact with them, but not sure how it's working in the actual site as I never worked with Angular.

尝试使用Selenium,尽可能地模拟用户交互。如果单击输入提示日历,请使用日历而不是发送密钥。

Try, with Selenium, to emulate the user interactions as much as possible. If clicking the input prompts a calendar, use that instead of sending keys.

您可能要检查的是与之交互时属性和字段的变化方式(使用Firefox的控制台进行操作,因为它发生的地方),以查看您写入的输入是否实际上是该输入,或者单击该焦点时将其发送到另一输入;等等。

Something that you may want to check is how the attributes and the field changes when you interact with it (do it with Firefox's console, as it is where it happens), to see if the input you write to is actually that one or when clicked the focus is sent to another one; etc.

这篇关于FireFox无法将密钥发送到日期选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆