Discussion:
[wtr-general] document object could not be used in watir-webdriver
AROCKIA JERALD
2017-07-04 15:37:09 UTC
Permalink
Hi all,

I am migrating from watir-classic to watir-webdriver to support ms edge
browser testing. I am facing an issue with *document object *which was
specific to IE. There is no direct way to refer document object using
watir-webdriver. Below is the code am referring and its exception. Can this
group help me on this to overcome this issue?

*Code:*

Watir::Wait.until(@entrySelectionTimeout) {

((control.document.invoke("currentStyle").backgroundColor).eql?
@selectedColor) &&
(is_status_bar_visible?.eql? false)
}

*Exception:*

Exception: undefined method `document' for
#<Watir::TableDataCell:0x46f00c8>

*Environment Used:*

Ruby Version - 2.2.6p396

*Gems used*
commonwatir (3.0.0)
watir (6.2.1)
watir-classic (4.3.0)
watir-webdriver (0.9.9)


is there any options to achieve my requirement as per the above code which
uses *webdriver*? However, same things were working perfectly fine with
watir-classic.
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2017-07-04 16:07:55 UTC
Permalink
Uninstall common Watir, Watir WebDriver and Watir classic. All the code you need is in Watir gem. You don't need to wait for document ready state, selenium does that automatically.
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2017-07-04 16:10:39 UTC
Permalink
You shouldn't need to specify waits at all if you are just interacting with elements. If you want real time help, you can join the Watir channel on selenium slack. http://seleniumhq.herokuapp.com
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Justin Ko
2017-07-04 20:44:32 UTC
Permalink
In general, you can achieve a similar interaction with the "document"
object by using the `execute_script` method.

For example, the line:

control.document.invoke("currentStyle").backgroundColor

Could be re-written as (assuming that "control" is a Watir::Element):

browser.execute_script('return arguments[0].currentStyle.backgroundColor',
control)

However, `currentStyle` is only defined in IE11, not Edge. As a result, the
above will not work in Edge. Instead you will need to use the
`getComputedStyle` method:

browser.execute_script('return
window.getComputedStyle(arguments[0]).backgroundColor;', control)

For this specific example, you can simply this further by using Watir's
built-in `style` method instead:

control.style('background-color')

- Justin Ko
Post by AROCKIA JERALD
Hi all,
I am migrating from watir-classic to watir-webdriver to support ms edge
browser testing. I am facing an issue with *document object *which was
specific to IE. There is no direct way to refer document object using
watir-webdriver. Below is the code am referring and its exception. Can this
group help me on this to overcome this issue?
*Code:*
((control.document.invoke("currentStyle").backgroundColor).eql?
@selectedColor) &&
(is_status_bar_visible?.eql? false)
}
*Exception:*
Exception: undefined method `document' for
#<Watir::TableDataCell:0x46f00c8>
*Environment Used:*
Ruby Version - 2.2.6p396
*Gems used*
commonwatir (3.0.0)
watir (6.2.1)
watir-classic (4.3.0)
watir-webdriver (0.9.9)
is there any options to achieve my requirement as per the above code which
uses *webdriver*? However, same things were working perfectly fine with
watir-classic.
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...