I have a Selenium/Java background, using Ruby/Capybara/Site Prism for the first time.
I would like to create an object and then interact with the elements on the page without using the .load method but after clicking on a link to get to the page that will make up my object.
I have an object like this:
require 'site_prism'
require 'capybara'
class OpportunityObject < SitePrism::Page
element :event_date, "td#00NC0000005hghU_ilecell"
end
My code looks like this:
require 'salesforce/objects/Opportunity'
require 'salesforce/salesforce_helper'
describe 'Create Opportunity', type: :feature do
before :all do
set_env
end
it 'Create Opportunity' do
login_to_salesforce
sleep 1
go_to_opportunities_page
sleep 1
#get_random_opportunity.click
@opportunity = OpportunityObject.new
puts @opportunity.event_date.text
end
end
The error I am getting is:
The given selector #00NC0000005hghU_ilecell is either invalid or does not result in a WebElement. The following error occurred:
InvalidSelectorError: An invalid or illegal selector was specified
The assignment of OpportunityObject is not happening as I would expect. I expect @opportunity to be an OpportunityObject with the accessible member being event_date. @opportunity appears to be an OpportunityObject but does not have any members defined.
I do not want to .load the page as I may not know what the URL is at the time. However, I do know I will be on the page and would like to define the object with specific page elements.