0
votes

I have downloaded PhantomJS and added the code below to my script:

Selenium::WebDriver::PhantomJS.path = 'C:\phantomjs-2.1.1-windows\bin\phantomjs.exe'
  @browser = Watir::Browser.new :phantomjs
  @browser.goto "www.samplewebsite.com"

Then I getting below error message:

Watir::Exception::ObjectDisabledException: element present and enabled, but timed out after 30 seconds, waiting for

"ctl00$ContentPlaceHolder1$Login1$UserName",

:tag_name=>"input"}> to not be disabled

Here is the code in the login.rb file:

def browser()
    Watir::Wait.until{@browser.text.include? 'Login'}
end

def credentials()
    @browser.wait
    username = @browser.text_field(name:"ctl00$ContentPlaceHolder1$Login1$UserName").send_keys 'abcd123' #Is this line of code showing the error

    password = @browser.text_field(name:"ctl00$ContentPlaceHolder1$Login1$Password").send_keys'Password'
end
2
The error says that the text field is disabled. Is it? Have you tried another browser such as Chrome? - Justin Ko
I have tried on other browsers and is working fine. Only Phantomjs is showing this error. - user3341382
Just want to mention my project is in Page Object style do you think that might be the issue? because the login method is in a separate .rb file. - user3341382
I have tried it on a single .rb file the issue above has something to with the Page Object style. Does anyone know how to make it work? Thanks - user3341382
If you think it's related to Page Object, it would help to show that part of your code. Though, given that it works in other browsers, I would be tempted to think it is a PhantomJS problem. - Justin Ko

2 Answers

0
votes

I'm pretty sure it is This Bug. It's been fixed in Watir 6.8.2, which was released yesterday.

0
votes

Read some post from other sources and I tried maximize the window: @browser.window.maximize then it worked! And yes this issue is not related to Page Object. Regarding the error message I didn't write them, I copied and pasted it from my IDE log.