In my test automation project, I am using ruby with capybara, cucumber and selenium. (I already have devkit installed and chrome is starting normally)
When looking for an element in the site to select it, I am using the method driver.findElement (By.xpath (.... etc")
, but when executing cucumber, it is indicating the following error:
I already removed and reinstalled the selenium-webdriver
gem but it did not resolve.
Can someone help me in resolving why WebDriver
does not seem to be valid in this context?
code example
(finding button logout using tag img, because the element don't have name or id)
After('@logout') do
element = driver.findElement(By.xpath("//img[@src='/Portal/img/user.png']"));
element.click
end
Result cucumber execution
Feature: Login
Description feature
DevTools listening on ws://127.0.0.1:60121/devtools/browser/c0bacc6e-697a-4614-b82c-eb324d587df5
@logout
Scenario: Login_OK # features/support/login.feature:14
Given that i access the main portal page HRP # features/step_definitions/login_steps.rb:1
When do login using "abc123" and "abc123password" # features/step_definitions/login_steps.rb:5
Then system do login # features/step_definitions/login_steps.rb:10
And show message "Welcome to Portal." # features/step_definitions/login_steps.rb:14
undefined local variable or method `driver' for # (NameError)
./features/support/hooks.rb:4:in `After'
Failing Scenarios:
cucumber features/support/login.feature:14 # Scenario: Login_OK
1 scenario (1 failed)
4 steps (4 passed)
0m5.457s