My CSS alias looks like this:
module MyPage
def locator(key, *options)
hash = {
"FIRST_TABLE_CELL_HREF" => [ :css => '#my-table td:nth-child(1):first a']
}
end
I am trying to click on the alias using Ruby syntax:
@page.find("FIRST_TABLE_CELL_HREF").when_present.right_click
The issue I am facing is that it's a Javascript style alias and not working as expected.
So my question is, how can I convert this to a Ruby style css alias?
Note:
$('#my-table td:nth-child(1):first a')
executes successfully in browser console.
This is particularly important for @TitusFortner: When targeting a specific element, his approach holds true. However, considering my use of a business level language (Gherkin), I need to create a universal instruction. An example would be:
When I right click on the element "FIRST_TABLE_CELL_HREF"
. This instruction should correspond to:
When(/^I right click(?: on|)(?: the|) "([^\"]*)"$/i) do |scope|
@page.find(scope).when_present.right_click
end
Where @page = @browser.visit(SomePage)
, and
@browser = BrowserBase.new start_browser(ENV['BROWSER'])