Discussion:
[wtr-general] Question related to custom attribute with iphen
Jeff Fagot
2018-06-08 21:48:14 UTC
Permalink
Hello all,

I am using watir (6.10.2).

* GIVEN HTML *:
<div class="Dashboard_Widget_Toolbar_Item"
data-widgetapplicationid="Authentication.Application.431"
data-widgetconfigure="What I Want">

Because I am using PageObject, I have been used to create page elements
using custom attribute as so:

*PAGEOBJECT ELEMENT DEF: *Where I simply replace the iphen by an underscore
("-" => "_")
self.div(:my_widget, *data_widgetconfigure*: "What I Want")

Now you see me coming, when I wanted to validate the value of my attribute,
I came across the below:
@browser.my_widget_element.attribute_value(:data_widgetconfigure).nil?
# => true

While the correct way seems to be:
@browser.my_widget_element.attribute_value("data-widgetconfigure").nil?
# => false

My question is to know as to why can't I use the first validation but more
importantly why is it not erroring out?

Thanks
Jeff
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
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
2018-06-08 22:32:59 UTC
Permalink
Hi Jeff,

Hash keys are immutable, and therefore represented by Symbol instances by Ruby convention. The parameter passed into the method to obtain the value is not immutable, and therefore represented as a String instance. There is no exception because Ruby does not do any type checking by default. We could either do a String conversion or throw an argument error, I'm not sure which is better, honestly. Create an issue on watir github page with your preference and we can discuss the best way to handle it. Better yet, if you can figure out how to do that in the attribute value method yourself you can make a pull request and become a contributor to the protect as well. :)
Post by Jeff Fagot
Hello all,
I am using watir (6.10.2).
 <div class="Dashboard_Widget_Toolbar_Item" data-widgetapplicationid="Authentication.Application.431" data-widgetconfigure="What I Want">
PAGEOBJECT ELEMENT DEF: Where I simply replace the iphen by an underscore ("-" => "_")
self.div(:my_widget, data_widgetconfigure: "What I Want")
@browser.my_widget_element.attribute_value(:data_widgetconfigure).nil?
# => true
@browser.my_widget_element.attribute_value("data-widgetconfigure").nil?
# => false
My question is to know as to why can't I use the first validation but more importantly why is it not erroring out?
Thanks
Jeff
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
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.
Jeff Fagot
2018-06-09 16:22:12 UTC
Permalink
Hi Titus,

Thanks for your answer. I'm trying to get myself familiar with the project
before logging the issue one way or the other...

Jeff
Post by Titus Fortner
Hi Jeff,
Hash keys are immutable, and therefore represented by Symbol instances by
Ruby convention. The parameter passed into the method to obtain the value
is not immutable, and therefore represented as a String instance. There is
no exception because Ruby does not do any type checking by default. We
could either do a String conversion or throw an argument error, I'm not
sure which is better, honestly. Create an issue on watir github page with
your preference and we can discuss the best way to handle it. Better yet,
if you can figure out how to do that in the attribute value method yourself
you can make a pull request and become a contributor to the protect as
well. :)
Post by Jeff Fagot
Hello all,
I am using watir (6.10.2).
<div class="Dashboard_Widget_Toolbar_Item"
data-widgetapplicationid="Authentication.Application.431"
data-widgetconfigure="What I Want">
Post by Jeff Fagot
Because I am using PageObject, I have been used to create page elements
PAGEOBJECT ELEMENT DEF: Where I simply replace the iphen by an
underscore ("-" => "_")
Post by Jeff Fagot
self.div(:my_widget, data_widgetconfigure: "What I Want")
Now you see me coming, when I wanted to validate the value of my
@browser.my_widget_element.attribute_value(:data_widgetconfigure).nil?
# => true
@browser.my_widget_element.attribute_value("data-widgetconfigure").nil?
# => false
My question is to know as to why can't I use the first validation but
more importantly why is it not erroring out?
Post by Jeff Fagot
Thanks
Jeff
--
--
Before posting, please read
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to a topic in the
Google Groups "Watir General" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/watir-general/Dwed6fP6kwM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
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
2018-06-09 16:30:59 UTC
Permalink
Well, let us know if we can help. If you want to discuss anything, you can
find us in the #watir channel of the Selenium Slack
Org: http://seleniumhq.herokuapp.com/

Titus
Post by Jeff Fagot
Hi Titus,
Thanks for your answer. I'm trying to get myself familiar with the project
before logging the issue one way or the other...
Jeff
Post by Titus Fortner
Hi Jeff,
Hash keys are immutable, and therefore represented by Symbol instances by
Ruby convention. The parameter passed into the method to obtain the value
is not immutable, and therefore represented as a String instance. There is
no exception because Ruby does not do any type checking by default. We
could either do a String conversion or throw an argument error, I'm not
sure which is better, honestly. Create an issue on watir github page with
your preference and we can discuss the best way to handle it. Better yet,
if you can figure out how to do that in the attribute value method yourself
you can make a pull request and become a contributor to the protect as
well. :)
Post by Jeff Fagot
Hello all,
I am using watir (6.10.2).
<div class="Dashboard_Widget_Toolbar_Item"
data-widgetapplicationid="Authentication.Application.431"
data-widgetconfigure="What I Want">
Post by Jeff Fagot
Because I am using PageObject, I have been used to create page elements
PAGEOBJECT ELEMENT DEF: Where I simply replace the iphen by an
underscore ("-" => "_")
Post by Jeff Fagot
self.div(:my_widget, data_widgetconfigure: "What I Want")
Now you see me coming, when I wanted to validate the value of my
@browser.my_widget_element.attribute_value(:data_widgetconfigure).nil?
# => true
@browser.my_widget_element.attribute_value("data-widgetconfigure").nil?
# => false
My question is to know as to why can't I use the first validation but
more importantly why is it not erroring out?
Post by Jeff Fagot
Thanks
Jeff
--
--
Before posting, please read
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to a topic in the
Google Groups "Watir General" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/watir-general/Dwed6fP6kwM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
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.
Jeff Fagot
2018-06-11 15:45:05 UTC
Permalink
I do not think I am knowledgeable enough to decide what direction to go
with this "custom attribute value type" issue. Although as a user personal
preference, I believe I certainly would prefer to make it work the way I
intended to use it, which if I understand your 2 options would be to do a
String conversion.
So before, I go ahead and log the issue, I wanted to confirm with you that
I understand properly the 2 suggested options (String conversion vs
throwing an argument error)
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
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...