1

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.

Nat Ritmeyer
  • 5,634
  • 8
  • 45
  • 58
  • The exception is simply complaining that the CSS-selector is not valid. The problem is with the id starting with a number (see [ID's Cannot Start With a Number](http://css-tricks.com/ids-cannot-start-with-a-number/)). Everything will probably work if you just change the selector to `td[id='00NC0000005hghU_ilecell']`. – Justin Ko Nov 04 '14 at 19:20
  • I tried td[id='00NC0000005hghU_ilecell'] and td[id$='hghU_ilecell'] neither worked. This code is trying to work against Salesforce. I would suspect Salesforce would know how to use ids (I guess I am wrong). Also, using my original selector works in Firebug. – dadams.qa.chi Nov 05 '14 at 20:55
  • It would definitely be easier for us to help if you could extract the relevant HTML and create a minimal working script that shows the problem. – Justin Ko Nov 05 '14 at 21:17
  • Above is the td I am trying to extract. Salesforce uses a TON of attributes so I stripped out all that is not relevant. My minimal script is in my original post. – dadams.qa.chi Nov 06 '14 at 21:48
  • I figure it out. I am scrapping site_prism in favor of straight up Selenium. site_prism is a great concept but does not seem to work for how I want to implement pages. – dadams.qa.chi Nov 10 '14 at 21:47

0 Answers0