FireFox cannot sendkeys to date picker

流过昼夜 提交于 2020-01-06 05:56:07

问题


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:

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");

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


回答1:


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.

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.

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.



来源:https://stackoverflow.com/questions/48500284/firefox-cannot-sendkeys-to-date-picker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!