Testing with cucumber and selenium: how can I see what it sees in the browser?

I am testing a script in Rails with Cucumber and it returns saying that it cannot find the edit link to click. If I go to the page myself, it's there. Obviously, I am doing something wrong, but I do not see it.

If I add the @selenium tag before my script, it runs tests in Firefox. But I see that the browser is open and closed, and if it does not require interaction with me (for example, to confirm the deletion), it passes before I can see what it is doing.

Is there a way to see what it sees in the browser and step by step?

+3
source share
7 answers

, , :

Then show me the page

, .

, : , :

Then /^I pause for a while$/ do
  sleep 30
end

30 , , .

+8

: " "

+7

, Cucumber

Then /^Wait for keypress$/ do
  STDIN.getc 
end

, . , .

+2

, , :

@leave_the_window_open
@javascript
Feature: The failing feature you want to click through
(...)

. After - :

After('@leave_the_window_open') do |scenario|
  if scenario.respond_to?(:status) && scenario.status == :failed
    print "Step Failed. Press Return to close browser"
    STDIN.getc
  end 
end

.

Voilá: , enter . .

+1

, -? .

0

ask , , . Firebug , . . , Firebug Cucumber CSS/JS ..

:

res = ask('Where is that error coming from??')

, , - , .

- ruby ​​ . - , , .

0

Ruby pry-nav - https://github.com/nixme/pry-nav

Add the following to your gemfile: gem 'pry' gem 'pry-remote' gem 'pry-nav'

Then add the string 'binding.pry' to the step definition where you want to split

Then you can use the step, then continue from the command line to execute your code. For example, you get a console function. you can evaluate expressions

0
source

Source: https://habr.com/ru/post/1774182/


All Articles