Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easy/Safe way to add custom widgets in subclasses? #410

Open
imjonsnooow opened this issue Feb 14, 2017 · 6 comments
Open

Easy/Safe way to add custom widgets in subclasses? #410

imjonsnooow opened this issue Feb 14, 2017 · 6 comments
Labels

Comments

@imjonsnooow
Copy link
Contributor

imjonsnooow commented Feb 14, 2017

Hi team,

I've found a use-case where the custom widgets are less flexible than is ideal:

require 'page-object'

class One
  include PageObject
end

class GxtTable < PageObject::Elements::Table
  
  protected
  def child_xpath
    ".//descendant::tr"
  end
end

PageObject.register_widget :gxt_table, GxtTable, :div

class Two < One
  gxt_table(:a_table, :id => "top_div_id")
end

If we try to run this code, we will get a NoMethodError: undefined method 'gxt_table' for Two:Class. It seems that when you register_widget, one of the page-object modules are enhanced to have the appropriate methods, but those methods do not end up on classes that have already included PageObject.

Re-including PageObject does fix the issue, but I'm unclear on whether or not doing this would cause any unintended consequences. Mostly looking for advice, here.

Thank you!

@djangofan
Copy link

I am also very interested in whatever solution this is for this. I would also like to have a page object contain various widgets (smaller page objects) representing different parts of a page. It's not clear how to do this from reading the docs, unless I overlooked it. @cheezy

@cheezy
Copy link
Owner

cheezy commented Mar 6, 2017

I'm going to make a release today that will not include a fix for this. I will make it a focus on the next release which should be in a week or so.

@cheezy
Copy link
Owner

cheezy commented Sep 22, 2017

@djangofan you should look at page_sections. They are exactly what you are looking for. I included examples of this in the last release of my book.

@cheezy
Copy link
Owner

cheezy commented Sep 22, 2017

@imjonsnooow I've looked over this briefly and really do not know why it is not working. If this is important, I will take the time to try to resolve it. As you said above, simply including the PageObject gem in the subclass resolves the issue. Is this a valid resolution for you?

@imjonsnooow
Copy link
Contributor Author

@cheezy - this isn't a huge priority for me right now, so I'm okay with the workaround identified (as it has not caused any adverse effects that I have noticed) :)

@jkotests jkotests added the bug label Nov 21, 2018
@jkotests
Copy link
Collaborator

A possible solution may be https://stackoverflow.com/a/14631604/1200545

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants