开发者

How can I make a text_field that is disabled until typed into enabled using firewatir?

开发者 https://www.devze.com 2023-03-10 06:07 出处:网络
When attempting to setup a Job Title the \"add job title\" buttons are hidden until text is entered. Using the following code to add a job title the disabled button does not become enabled.

When attempting to setup a Job Title the "add job title" buttons are hidden until text is entered. Using the following code to add a job title the disabled button does not become enabled.

browser.开发者_如何学JAVAtext_field(:name, "addJobTitleValue").set firstJobTitle

How can I make a text_field that is disabled until typed into enabled using firewatir?

How can I make a text_field that is disabled until typed into enabled using firewatir?

Is there a way to set the text_field and have the button become enabled?


By using the watir-webdriver versus firewatir I was able to use these lines of code to enable the button:

browser.text_field(:name, 'addJobTitleValue').clear
browser.text_field(:name, 'addJobTitleValue').fire_event 'onclick'
browser.text_field(:name, 'addJobTitleValue').send_keys firstJobTitle

This has solved the problem to me and convinced me officially to start the switch to watir-webdriver.


I would expect that using one of firewatir's .fire_events would have had the same effect as the chosen answer, and avoided the need to swap over to watir-webdriver.

E.g.

browser.text_field(:name, 'addJobTitleValue').fire_event("onclick")

replacing onclick with the other javascript events, until one triggers the button to be enabled.

Without an actual page to experiment with, I'd guess at .fire_event("onchange") or .fire_event("onkeydown") or .fire_event("onkeyup") being able to enable the button you wanted to press.

0

精彩评论

暂无评论...
验证码 换一张
取 消