site-prism / site_prism Goto Github PK
View Code? Open in Web Editor NEWLicense: BSD 3-Clause "New" or "Revised" License
License: BSD 3-Clause "New" or "Revised" License
supposed there is an element some_element
defined as
element :some_element, 'li'
and code
if some_page.has_some_element?
some_page.some_element
end
Above example will raise an error if li
element is not unique on the line
some_page.some_element
:
Capybara::Ambiguous Exception: Ambiguous match, found N elements matching visible css "li"
This is happening in
site_prism/lib/site_prism/page.rb
Line 113 in 34a1ec9
count: 1
option for element
.
This issues can be seen in various places there?(:some_element)
, all_there?
etc will also return true for above example. But will fail if you try to interact with element
has_some_element?
to return false (maybe with warning "found multiple elements")
has_some_element?
returns true but some_element
fails with above error
module Fix
def element(name, *find_args)
hash_args = find_args.last
hash_args.merge!(count: 1) unless hash_args.has_key?(:count)
super(name, *find_args)
end
def section(name, *find_args)
hash_args = find_args.last
hash_args.merge!(count: 1) unless hash_args.has_key?(:count)
super(name, *find_args)
end
end
SitePrism::DSL::ClassMethods.prepend(Fix)
problem upgrading site_prism from 2.14 to 2.15
I don't have this problem with 2.14.
bumping this gem is the only changes I have
capybara
2.18 / selenium-webdriver (3.142.7)elements should be found, test should pass.
when I access the rules
section, trying to simply expect(dialog.rules.length).to eq(2)
I get this error.
*** Selenium::WebDriver::Error::StaleElementReferenceError Exception: stale element reference: element is not attached to the page document
(Session info: chrome=81.0.4044.138)
class EditThresholdRule < SitePrism::Section
element :condition_type, "select[name='condition_type']"
element :action_type, "select[name='action_type']"
element :action_options_rounding, "select[name='action_options_rounding']"
element :action_options_minutes, "select[name='action_options_minutes']"
element :destroy, "a.destroy_link"
end
class EditThresholdDialog < UiDialog
element :save_and_apply, "button.primary-button"
element :select_allow, "select[name='allow']"
sections :rules, EditThresholdRule, "li.resolution-rules li.rule"
element :add_rule, "li.resolution-rules li.actions button"
end
probably important to add, these elements are hidden/shown via angular, but I see them in the browser when I stop the debugger
thanks
site_prism
and capybara
)
To be able to define a class extending Section
, e.g. class SomeSection < SitePrism::Section; end
An error occurs:
Failure/Error: class SomeSection < SitePrism::Section
NameError:
uninitialized constant SitePrism::Section::Forwardable
extend Forwardable
^^^^^^^^^^^
Simply run the line of code under Expected Behavior in a fresh project.
Of course, this is very easily solvable by doing require 'forwardable'
anywhere in the project, but it seems like this should be done in SitePrism.
The Betterment logo is outdated, however I lack permissions to edit the wiki directly. Would you be able to swap out
[<img src="http://static.squarespace.com/static/51eef63ae4b089778deccb24/t/522cb69be4b074119b21db97/1375925773732/Betterment.png" width="300"/>](https://www.betterment.com)
with
[![Betterment](https://www.betterment.com/hubfs/Graphics/shared-assets/betterment-logo.png)](https://www.betterment.com)
Thanks!
When defining a new class inheriting from SitePrism::Page which defines a :attributes
section, the default helper have_attributes
from RSpec gets overwritten.
Here is a RSpec test to showcase the issue:
RSpec.describe "have_attributes" do
let(:struct) { Struct.new(:a, :b, :c) }
it "checks that the object has the listed attributes" do
expect(struct.new(1, 2, 3)).to have_attributes(a: 1, b: 2, c: 3)
end
end
RSpec.describe "a Page implementing an attributes section" do
let(:struct) { Struct.new(:a, :b, :c) }
context "when it is defined" do
let!(:page) do
Class.new(SitePrism::Page) do
section :attributes, '.foo' do
element :unused_element, '.btn'
end
end
end
it "breaks `have_attributes`" do
expect(struct.new(1, 2, 3)).to have_attributes(a: 1, b: 2, c: 3)
end
end
context "after it has been defined once" do
it "breaks `have_attributes`" do
expect(struct.new(1, 2, 3)).to have_attributes(a: 1, b: 2, c: 3)
end
end
end
The matcher for have_attributes should be: https://relishapp.com/rspec/rspec-expectations/v/3-9/docs/built-in-matchers/have-attributes-matcher.
From what I saw in the docs and in the code, SitePrism::RSpecMatchers
seems to define new have_*
matchers. Is this still necessary since RSpec already have the have_xxx
matcher?
This issue should be fixed in-line with all other areas
We should be using wait
key here and simplify the method
seconds
has to be the first value i.e. displayed?(3)
instead of displayed?(wait: 3)
N/A
Wiki update
[email protected]:ineverov/site_prism-1.wiki.git
How to handle Dynamic locators??
For E.g //input[contains(text()='sometext')] where sometext must be replaced by a certain value.
As in Site prism it returns CapybaraNodeElements, should I define these kind of xpaths as string in Locators section?
When I use SitePrism with non rails, I can't inherit from SitePrism::Page.
On rails project this is working correctly, cause gems are loaded in spec_helper
Only workaround for this is not to require site-prism in spec helper and add in spec_helper:
require 'bundler'
Bundler.require(:default)
OS: Ubuntu 16.04
SitePrism version - 3.3
Capybara version - 3.25.0
Fix unit tests to use a dummy capybara app
N/A
Unit tests to be easier to write, removal of rspec stubs
Reliant on rspec stubs
# define full html
html = <<-HTML
<html><head></head><body><a href="#">a</a><table id="my-table"></table></body></html>
HTML
# define minimal positive puma app
Capybara.app = ->(_env) { [200, {}, html] }
# continue with loading pages as per usual
page = SitePrism::Page.new
page.load
page.html # dumps the capybara app html forced
Running the element_checker_spec on its own fails in isolation
Ubuntu 18.04 LTS - site_prism at master
rspec spec/site_prism/element_checker_spec.rb passes
rspec spec/site_prism/element_checker_spec.rb fails. Likely due to some leaking cross specs.
Pull master, run in isolation
This is more of a question than an issue. We have “elements” on the page that require more sophisticated set of actions to interact with the element beyond the set of public API methods on capybara’s Element. For example our “masked text died” requires passing in an option to set
or in we have a date picker that needs some trickery to be able to set its value. I’d like to subclass Element and wrap those concepts up. It would be cool if this gem can have a declaration to load those classes instead of the normal Element. If that’s out of this gems control then perhaps a convention of a “Element Wrapper” would work:
element :foo, “#some-I’d”, wrapper: SpecialTextField
Where the wrapper just takes in the capybara element on initialization and proxies calls to the element. Within the wrapper, you can define methods that are special to your weird element.
The following link in the README is broken
Find the pretty documentation here: http://rdoc.info/gems/site_prism/frames
site_prism v 3.3 installed and working as before
site_prism v 3.3 is auto installed with bundle_install but now gives following error when running tests:
uninitialized constant SitePrism::Section
Did you mean? Exception (NameError)
it ran successfully last time at 01 Jul 2019 at 13:39:38 BST
I didn't change anything on my code base, it used to work fine with site_prism (3.2) but after bundle install now I have site_prism (3.3) and site_prism-all_there (~> 0.1.0) site_prism-all_there (0.1) in my Gemfile.lock and my tests doesn't run anymore and throws below error.
Headers_and_footers_rb in shared sections:
class Header < SitePrism::Section
set_default_search_arguments '.header'
element :provider_name, '.header__provider-name'
element :provider_logo, '.header__service-logo'
end
admin_homepage.rb that uses headers_and_footers
require 'capybara'
require 'capybara/cucumber'
require 'selenium-webdriver'
require 'site_prism'
require_relative '../page_objects/shared_sections/headers_and_footers'
require_relative '../page_objects/shared_sections/navigation_bars'
class AdminHomePage < SitePrism::Page
set_url '/home.htm'
section :header, Header
section :footer, Footer
end
and then calling it from .rb
When(/^Admin clicks allocate cases button$/) do
@home = AdminHomePage.new
@home.quick_links.allocate_cases_link.click
end
I would like to have the ability to select elements by the text they contain. For example:
class DummyPage < SitePrism::Page
element :homepage_button, ".button", text: "Homepage"
end
This could be implemented using Capybara's page.users_with_text
.
This same request was made in an issue on the old repo, but I'd like to revisit the decision not to implement this. That decision seems to have been made based on an opinion that selecting elements by text is bad. However, in my opinion, feature tests that use capybara and site_prism should test things as closely to the user's perspective as possible. User's do not know about CSS classes, ids, etc. All they see when they're viewing the page is the text and boxes and such. If I were to describe to a user how to navigate to something, I would not say "Click on the #button-homepage button" I would say "Click the button with the text "Homepage"". I would like to do the same in my feature tests.
This approach also has the advantage that it decouples the tests from the HTML structure a bit. If CSS classes or IDs change because of design or business decisions, but the button with that text is still on the page, the test does not break.
When running capybara matchers, the current_scope
failure is only triggered for have_link. have_text seems to be fine. Maybe worth investigating more.
@tgaff - This is the 3.30 bug we found with capybara.
test runs
current_scope failure
use have_link
on site_prism 3.42 with capybara > 3.30
site_prism
and capybara
)Able to install both latest versions of site_prism and site_prism-all_there
# after adding site_prism-all_there to Gemfile
~/dev/app$ bundle
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/.
You have requested:
site_prism-all_there ~> 1.0, >= 1.0.1
The bundle currently has site_prism-all_there locked at 0.3.2.
Try running `bundle update site_prism-all_there`
If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
~/dev/app$ bundle update site_prism-all_there
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Bundler could not find compatible versions for gem "site_prism-all_there":
In Gemfile:
site_prism-all_there (~> 1.0, >= 1.0.1)
site_prism (~> 3.7) was resolved to 3.7.3, which depends on
site_prism-all_there (>= 0.3.1, < 1.0)
Gemfile
:
# Gemfile
...
gem 'site_prism', '~> 3.7'
gem 'site_prism-all_there', '~> 1.0', '>= 1.0.1'
...
bundle install
I want to use an instance variable to receive a string and pass to element selector, but it seems that initialize method is running after the elements and his value is nil.
class AgentChat < SitePrism::Page
element :chat_button_hover, '.ft-chatAgent'
element :chat_list_item, '.ft-list-agent .item', text: @agent_name #nil value
element :chat_input, '.chat-resizable.active .form .emojionearea-editor'
element :chat_list, '.chat-resizable.active', text: @agent_name #nil value
def initialize (agent_name)
@agent_name = agent_name
end
def chat_agent_hover
chat_button_hover.hover
end
def open_chat
chat_list_item.click
end
def send_message(message, enter_key)
chat_input.click
chat_input.send_keys(message, enter_key)
end
def get_messages_on_chat
chat_list.text
end
end
Here is when i create an instance of this AgentChat class.
Dado("abriu o chat do agente {string}") do |name|
@date = Date.today.to_s
@chat_send_agent = AgentChat.new(name)
@chat_send_agent.chat_agent_hover
@chat_send_agent.open_chat
end
Hope someone could help me out.
I stumbled upon a situation where I need to wait for an element that resides in a section block. I would like to know how can I solve this problem. Thank you!
From site_prism created by faceless7171: natritmeyer/site_prism#344
Right now we can specify expected_elements for a page/section class. It would be great if we will have ability to specify elements that we are not expecting to see on the page by default.
Expected behavior:
ability to add elements/sections on the page/section description to the not expected elements, so be_all_there matcher will ignore this elements/sections.
Example:
class Home < SitePrism::Page
set_url '/index.htm'
set_url_matcher /google.com\/?/
section :s1, 's1' do
element :e1, 'e1'
element :e2, 'e2'
section :s2, 's2' do
element :e3, 'e3'
element :e4, 'e4'
element :e5, 'e5'
sections :s3, 's3' do
element :e6, 'e6'
end
end
end
element :e7, 'e7'
not_expected_elements :e2, :e7
end
Then expect(HomePage).to be_all_there
will check only existence of e1, s2 elements.
Does click wait for an element to be visible before clicking it or does it depend on certain factors or Capybara settings? If so, which ones?
I have a flaky test where clicking a link sometimes brings us to the linked page and sometimes does not and no request for that page is sent to the server. I'm wondering if it's because the link is not yet visible.
The first of a series of Issues I'm creating for outstanding "small" tasks that people can contribute to if they want to get involved with site_prism as an Open Source Project.
Our low_spec gemfile and suite gemspec need validating and perhaps bringing slightly more up to date
The suite gemspec should always be tracking as far back as it can do realistically, but our main two dependencies (addressable and capybara), shouldn't be so ancient that they are out of support.
Investigate at what point we cover a reasonable amount of users still, and then update the files accordingly.
We may also be able to go back down from 3 gemfiles to 2 in travis, which would massively speed up our CI times.
bundle exec rake
should still pass fully green.
browserless/chrome:1.31-chrome-stable
Docker imageThe following works as described in the docs:
my_page.sections.first.within do
assert_text "some text"
end
my_page.form.within do
assert_text "some text"
end
In both cases I see:
NoMethodError: undefined method `within' for Obsolete #<Capybara::Node::Element>:Capybara::Node::Element
I see these exceptions even for the simplest scenarios:
class NewGroupPage < SitePrism::Page
set_url "/groups/new"
section :form, SitePrism::Section, "#new_message"
load_validation { has_form? }
end
test "page should work" do
page = NewGroupPage.new
page.load
page.form.within do
assert_text "Save me"
end
end
site_prism 3.4.1
, capybara 3.30.0
page.loaded? #=> raise exception if there are no load validations
page.loaded? #=> true if there are no load validations
class ComplexPage < SitePrism::Page
set_url "/complex-page"
# nothing in here
end
complex_page = ComplexPage.new
# ...
click_on "Go to complex page"
expect(complex_page).to be_loaded
I think it's unexpected that loaded?
returns true
by default. If the page doesn't know how to check if it's been loaded (ie. there are no load validations defined) then it should raise an error.
Hi,
Is there a way to set an element
Programmatically?
The app I'm testing is a have a user of [data-test-id]
. This identifier usually has an id
that is related to a specific object of the application.
ex:
We have a list of users and each row have a <li data-test-id="user-434353"> Name </li>
What is the best approach to find those elements?
From site_prism created by tgaff: natritmeyer/site_prism#395
section :my_section, MySection, 'div.locator'
@page.my_section do |section|
section.something # executes
end
sections :my_sections, MySection, 'div.locator' #
@page.my_sections.first do |section|
section.something # does not execute block
end
While the second behavior is not explicitly documented, one would it expect it to work since :sections
is in many ways an Array-like of :section
. Not sure whether this should be considered a bug or feature-request, but failing to execute the block could lead to incorrectly-passing tests.
We can exec inside a section similar to Capybara within
functionality on an individual section. But on an array of sections generated by :sections
this does not work.
I expected that my block would be executed when passed as @page.my_sections {|s| raise 'ermagerd'}
Code in the block is not exec'd
cucumber -r features
In the below I verify that on the Section features we do execute the contents of the block.
However when it comes to the Sections features, the same functionality fails - the block is not executed. Specifically the tests fail with:
Then I can execute in the context of a section using a block # features/step_definitions/sections_steps.rb:22
expected: 2
got: 0
(compared using ==)
(RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/sections_steps.rb:39:in `"I can execute in the context of a section using a block"'
features/sections.feature:21:in `Then I can execute in the context of a section using a block'
Failing Scenarios:
cucumber features/sections.feature:19 # Scenario: access elements in the section by passing a block
91 scenarios (1 failed, 90 passed)
229 steps (1 failed, 228 passed)
0m23.693s
Patch that reproduces this behavior
diff --git a/features/sections.feature b/features/sections.feature
index 1705336..4f9aee8 100644
--- a/features/sections.feature
+++ b/features/sections.feature
@@ -15,3 +15,7 @@ Feature: Interaction with groups of elements
Scenario: anonymous sections collection
When I navigate to the nested section page
Then I can see a collection of anonymous sections
+
+ Scenario: access elements in the section by passing a block
+ When I navigate to the nested section page
+ Then I can execute in the context of a section using a block
diff --git a/features/step_definitions/section_steps.rb b/features/step_definitions/section_steps.rb
index a56cd57..45e5bb0 100644
--- a/features/step_definitions/section_steps.rb
+++ b/features/step_definitions/section_steps.rb
@@ -12,13 +12,19 @@ Then('I can see a section in a section') do
end
Then('I can access elements within the section using a block') do
+ block_inner_executions = 0
+
expect(@test_site.home).to have_people
@test_site.home.people do |section|
+ block_inner_executions += 1
+
expect(section.headline.text).to eq('People')
expect(section).to have_individuals(count: 4)
end
+
+ expect(block_inner_executions).to eq 1
end
Then('I cannot access elements that are not in the section using a block') do
diff --git a/features/step_definitions/sections_steps.rb b/features/step_definitions/sections_steps.rb
index f57cbe7..4e1f0c9 100644
--- a/features/step_definitions/sections_steps.rb
+++ b/features/step_definitions/sections_steps.rb
@@ -17,3 +17,24 @@ Then('I can see a collection of anonymous sections') do
expect(anonymous_sections.size).to eq(2)
end
+
+
+Then('I can execute in the context of a section using a block') do
+ block_inner_executions = 0
+
+ expect(@test_site.nested_sections).to have_search_results(count: 4)
+
+ @test_site.nested_sections.search_results.first do |sec|
+ block_inner_executions += 1
+ expect(sec).to be_an_instance_of(SitePrism::Section)
+ expect(sec).to have_text('Result 0')
+ end
+
+ @test_site.nested_sections.search_results.last do |sec|
+ block_inner_executions += 1
+ expect(sec).to be_an_instance_of(SitePrism::Section)
+ expect(sec).to have_text('Result 3')
+ end
+
+ expect(block_inner_executions).to eq 2
+end
I updated the chromedriver to be the same as the Google Chrome browser: version 80.
The same code works perfectly on a :selenium_chrome
mode, but it fails on a :selenium_chrome_headless
.
It always returns SitePrism::ElementVisibilityTimeoutError
, even passing a amount of seconds to wait for it.
The element is found between the set time.
It fails with SitePrism::ElementVisibilityTimeoutError
.
Piece of the code:
within_window(@topics_window) do
@topics_page.wait_until_sorter_view_visible(wait: 10)
@topics_page.sorter_view.click
puts "\t#{'=' * 27} \n| Tópico Mais Visualizado |\n #{'=' * 27}"
puts "\t#{@topics_page.topics.first.find('.title').text}"
end
When using a section which becomes stale, when trying to access any method or locator inside it, SitePrism should firstly try to regenerate the root_element and then if not, provide some API for doing so, to mitigate un-wanted StaleElements being caused by headers/footers being altered.
When using a section which becomes stale, when trying to access any method or locator inside it, a StaleElement is thrown
N/A
It's very useful for debugging purposes to have
missing_elements
method which will return self.class.expected_items - expected_elements_present_on_the_page
ViewComponent is a new library from Github that is gaining support quickly. It encapsulates views and partials into objects that can be easily rendered and tested. However, as far as I can tell, there is not a great way to use the Page Object Model and specifically site_prism with this awesome new tool.
In my head, I think the ideal way this would work is I would create a section class (inheriting from SitePrism::Section
), then instantiate that with the html output coming from render_inline(MyComponent.new(...)).to_html
from ViewComponent's helpers. Then I could interact with that in the same way I could any other section on a page. I could also reuse that section class in a feature test when I'm using a browser driver to interact with the page, getting double bang for my buck.
I'm not sure exactly what would be needed to make this work. Essentially I think I want to instantiate a Section
without a Page
, and without requiring capybara to pre-define a page
object. I'm not sure if this requires any changes to site_prism or even capybara, or if I'm just missing how to do this with the current version of the library.
Any help with this is greatly appreciated!
From the README
Find the pretty documentation here: https://rdoc.info/gems/site_prism/frames
This link is not working: https://rdoc.info/gems/site_prism/frames
It will be useful currently anonymous sections defined with block argument to have a class name.
Proposed solution: deduce_section_class
to be rewritten similar to this:
def deduce_section_class(base_class, &block)
klass = base_class
if block_given?
const_set(@_last_section_name.to_s.camelcase, Class.new(klass || SitePrism::Section))
klass = const_get(@_last_section_name.to_s.camelcase)
klass.class_eval(&block)
end
return klass if klass
raise ArgumentError, "You should provide descendant of \
SitePrism::Section class or/and a block as the second argument."
end
where @_last_section_name
is a name parameter from section/sections
call.
I'm currently working on an internal framework (going to make it public someday) for mobile automation based on site_prism which identify arguments based on element/section name and section/page class name
For example, I have a page object classes defined like this
# module SitePrismDSLExtension extend and override/monkeypatch some basic site_prism DSL methods
class BaseSection < Section
include SitePrismDSLExtension
end
class BasePage < Section
include SitePrismDSLExtension
end
class Row < BaseSection
set_default_search_arguments
element :column1
element :column2
end
class Home < BasePage
element :header
sections :rows1, Row
sections :rows2, Row do
element :column3
end
section :rows3, Row do
element :column4
end
end
This DSL extension identifies locator based on class name and element name. For example, a locator for column1
, column2
and default search args for section Row
will be looked in YAML file row.yml
;
header
, rows1
and rows2
in home.yml
;
column3
will be defined in home.yml
but nested
header:
locator: header_locator
# rows1 may use default locator
rows2:
locator: rows2_locator
column3:
locator: column3_locator
This allows to extract locators to another abstract layer and use config overlay to define locators based on device or platform (iOS and Android) without defining separate page object for same page structure in case locator differ for specific platform/device.
The logic of mapping depends on the class name. If the page class name is Home it will be looking for locators in home.yml. If section class name is Row it will be looking for locators in row.yml etc.
The problem arise for section definitions like rows2 with section name as well as a block. The actual class won't have a name (anonymous). Finding superclass of this class may slightly help, but will create another issue - row.yml
will have to hold locators for all the possible extensions of Row section and it will hold no binding to the parent section/page. To avoid this problem 2 things are needed:
Home::Rows2 < Row
and Home::Rows3 < Row
This should not be a breaking change as it only changes internal implementation.
For some reason, some of our specs fail consistently when all specs are run, but never fail when run individually. Using expect(page).to be_displayed
it will time out waiting for the page to be displayed (even bumping Capybara max wait to 10 seconds doesn't fix it), but always pass when run individually. This makes me think there is some kind of clean up that is not happening between test runs.
Pass consistently
Fails consistently when running entire suite.
Sorry, I'm not sure how to reproduce this issue. I wonder if maybe a timer from a previous spec is not getting cleaned up.
Ideally we should be able to configure when to run load validations in a nice clear way - Config option e.t.c.
N/A
Have some config switch that modifies the initialize method to run load validations
I currently modify my app class to run @class ||= Class.new.tap(&:when_loaded)
N/A
NB: This would not be viable for site_prism 3.x - It would need to go into a 4.x release. With the behaviour experimental so default turned off.
I'm developing automated tests with SitePrism, Ruby and Capybara and I didn't find a way to fill input dates when I'm using Site Prism.
I know I can use the Capybara's fill_in method and pass the field and the value in the parameters. But when I map the field in a page object, fill_in is not enough to my automation write the input date field with the date.
How can I work with Site Prism and Capybara together in this case, if it's possible?
Thanks!
From site_prism created by luke-hill: natritmeyer/site_prism#341
Need to re-triage this on a sample page. But it appears as though all SitePrism iFrame locators are queried at a Capybara.current_session
level. meaning any section scoping will be ignored.
All
If 2 iframes with same styling exist on a page at different scoping levels, you should be able to locate the relevant one within your page/section scope.
If 2 iframes with same styling exist on a page at different scoping levels, then you may get an ambiguous error or similar issues due to the code not working as intended
I have classic element(s) and section(s) definitions on page classes. I would like to use code completion while searching for those.
Example, while using ruby mine, you can find the methods inside page object class but you can not find the elements.
This would avoid wrong typing elements,
Finding available elements much faster,
Is there a pattern that I can change the page objects or element
to support this?
The first of a series of Issues I'm creating for outstanding "small" tasks that people can contribute to if they want to get involved with site_prism as an Open Source Project.
Our Test Suite is kind of mangled. We should be using spec/support files and including them in, instead of muddying the waters
All of our helpers should live in small diet files located in spec/support (And be namespaced under SpecSupport::xxx
Once we've done this, use RSpec to load these into the RSpec runtime, and then we can still access them across the suite.
As an extension, we could also look to isolate the shared_contexts and suchlike in their own support folders and load those in
bundle exec rake
should still pass fully green.
The first of a series of Issues I'm creating for outstanding "small" tasks that people can contribute to if they want to get involved with site_prism as an Open Source Project.
We have a series of rubocop overrides in rubocop_todo.yml
These need removing, and manually fixing up in the spec files.
You can fix up "some" of these, or all of these. Whatever you find easiest. There is a reasonable amount of work to fix up.
bundle exec rake
should still pass fully green.
I'm guessing this issue is related to the latest changes regarding autoload.
We're using Capybara 3.39.1. When upgrading site_prism from 4.0.0 to 4.0.1 we get this error on load (running rspec or rails itself, same result):
$ RAILS_ENV=test bin/rails c
$ /home/oboxodo/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/site_prism-4.0.1/lib/site_prism/page.rb:14:in `<class:Page>': uninitialized constant Capybara::DSL
include Capybara::DSL
^^^^^ (NameError)
from /home/oboxodo/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/site_prism-4.0.1/lib/site_prism/page.rb:13:in `<module:SitePrism>'
from /home/oboxodo/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/site_prism-4.0.1/lib/site_prism/page.rb:3:in `<main>'
...
Tests would run as they were running with v4.0.0.
"uninitialized constant Capybara::DSL"
Upgrade from 4.0.0 to 4.0.1 then run any rails command loading the app in test env.
Capybara 3.28.x includes code that throws keyword parameter deprecation warnings in Ruby 2.7 and does not work in Ruby 3+.
These issues were fixed in 3.30.0 and all versions up to 3.32.0 are supported by Ruby 2.4 (currently set in .ruby-version).
PR #78 increases the maximum allowed version and fixes a test broken by the upgrade
I have a table in a page that returns items that match certain filters. I am trying to write a test that verifies those rows have the correct values as the filters change, but I am unable to do this cleanly using matcher composition.
Here is some simplified code demonstrating the issue
class Row < SitePrism::Section
element :valueA, 'td:nth-of-type(3)'
element :valueB, 'td:nth-of-type(2)'
end
class TablePage < SitePrism::Page
set_url '/table_page'
sections :rows, OrderTableRow, '#my_table tbody tr'
end
describe 'table page' do
it 'updates the table with changing filters' do
items = []
items << createItem(valA: 'foo', valB: 'bar')
items << createItem(valA: 'baz', valB: 'boz')
item_matchers = items.map do |i|
have_attributes(valueA: have_text(i.valA), valueB: have_text(i.valB))
end
p = TablePage.new
p.load
expect(p).to have_rows(count: 2)
expect(p.rows[0].valueA).to have_text(items[0].valA) # this passes
expect(p.rows[0]).to have_attributes(valueA: items[0].valA) # this gives an error that valueA is a Capybara::Node::Element
expect(p.rows[0]).to match(valueA: items[0].valA) # this gives an error that valueA is a Row
expect(p.rows).to match(item_matchers) # this is what I want to write but gives the error above
end
I am trying to upgrade to the latest SitePrism and I found out the error I am getting started happening at 2.14
I can not find a mention about a breaking change in the changelog
https://github.com/site-prism/site_prism/blob/master/CHANGELOG.md#214---2018-06-22
it seems that a new validation was introduced to ensure Sections has child elements.
but in the large project I am working on, its not straight forward to defined all of those.
Note that I never setup site_prism and I dont have previous experience with this gem.
my tests should pass.
I wish there might be a configuration option to maybe fallback to the previous behaviour
or sufficient documentation to help us upgrade.
I don't believe such breaking changes should have occurred before 3.0 IMO
ArgumentError:
You should provide descendant of SitePrism::Section class or/and a block as the second argument.
# /root/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/site_prism-2.14/lib/site_prism/element_container.rb:258:in `deduce_section_class'
# /root/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/site_prism-2.14/lib/site_prism/element_container.rb:247:in `extract_section_options'
# /root/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/site_prism-2.14/lib/site_prism/element_container.rb:77:in `sections'
# ./spec/page_objects/employees/totals_based_payroll_page.rb:8:in `<class:TotalsBasedPayrollPage>'
this is how my sections was defined
sections :list_items, PayrollItem, 'tbody tr'
If I have an element that represents an input element with a value, I should be able to wait for that element to be visible with a particular value like Capybara's find_field(id: 'someid', with: 'somefieldvalue')
E.g.
class MyPage < SitePrism::Page
element :my_input, '#input-id'
end
page = MyPage.new
page.load
page.wait_for_my_input_visible(with: 'somefieldvalue')
page.wait_for_my_input_visible(text: 'somefieldvalue') is the closest I can get and it does not work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.