Skip to content

Commit 49a7dd4

Browse files
Fix few slides (#216)
Co-authored-by: Denis Zemlyaniy <denis.zemlianoy@gmail.com>
1 parent 2cb026c commit 49a7dd4

File tree

1 file changed

+29
-31
lines changed

1 file changed

+29
-31
lines changed

slides/automation-qa/capybara.markdown

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ spec/support/capybara.rb <!-- .element: class="filename" -->
101101

102102
After previous execution write:
103103

104-
spec/feature/test_spec.rb <!-- .element: class="filename" -->
104+
spec/features/test_spec.rb <!-- .element: class="filename" -->
105105

106106
```ruby
107107
visit('/') # Capybara will visit `http://www.google.com`
@@ -119,7 +119,7 @@ visit('/') # Capybara will visit `http://www.google.com`
119119

120120
--
121121

122-
By default, Capybara uses the `:rack_test` driver which does not have any support for executing JavaScript.
122+
By default, Capybara uses the `:rack_test` driver which does not have any support for executing JavaScript.
123123
Drivers can be switched in Before and After blocks. Some of the web drivers supported by Capybara are mentioned below.
124124

125125
- Non JS support
@@ -194,19 +194,42 @@ The [Selenium wiki](https://github.com/SeleniumHQ/selenium/wiki/Ruby-Bindings) h
194194

195195
--
196196

197+
## `type: :feature`
198+
199+
Feature specs are marked by `type: :feature` or if you have set
200+
`config.infer_spec_type_from_file_location!` by placing them in `spec/features`.
201+
202+
spec/features/test_spec.rb <!-- .element: class="filename" -->
203+
204+
```ruby
205+
RSpec.describe 'some test placed in features folder' do
206+
end
207+
```
208+
209+
or
210+
211+
spec/test_spec.rb <!-- .element: class="filename" -->
212+
213+
```ruby
214+
RSpec.describe 'some test with type feature', type: :feature do
215+
end
216+
```
217+
218+
--
219+
197220
## `js: true`
198221

199222
Use `js: true` to switch to the `Capybara.javascript_driver` (:selenium by default), or provide a :driver option to switch to one specific driver. For example:
200223

201-
spec/feature/test_spec.rb <!-- .element: class="filename" -->
224+
spec/features/test_spec.rb <!-- .element: class="filename" -->
202225

203226
```ruby
204227
RSpec.describe 'some stuff which requires js', type: :feature, js: true do
205228
it 'will use the default js driver'
206229
end
207230
```
208231

209-
spec/feature/second_test_spec.rb <!-- .element: class="filename" -->
232+
spec/features/second_test_spec.rb <!-- .element: class="filename" -->
210233

211234
```ruby
212235
RSpec.describe 'some stuff which not requires js', type: :feature do
@@ -281,7 +304,7 @@ click_button('button_text') # click button by button text
281304
fill_in('field_name', with: 'your_value') # fill text field
282305

283306
choose('radio_button_name') # choose radio button
284-
check('checkbox_id') # check in checkbox
307+
check('checkbox_id') # check in checkbox
285308
uncheck('checkbox_name') # uncheck in checkbox
286309

287310
select('option', from: 'select_box_name') # select from dropdown
@@ -336,7 +359,7 @@ For scenarios where basic the DSL cannot help, we use xpath and CSS selectors (C
336359

337360
To find a specific element and click on it we can use:
338361

339-
spec/feature/test_spec.rb <!-- .element: class="filename" -->
362+
spec/features/test_spec.rb <!-- .element: class="filename" -->
340363

341364
```ruby
342365
find('xpath/css').click
@@ -406,28 +429,3 @@ save_and_open_screenshot
406429
```
407430

408431
Screenshots are saved to `Capybara.save_path`, relative to the app directory. If you have required `capybara/rails`, `Capybara.save_path` will default to `tmp/capybara`.
409-
410-
--
411-
412-
## Again `Pry`
413-
414-
You can remember what is pry [here](http://localhost:4000/slides/automation-qa/rails-structure#/12/1)
415-
416-
Remember you should place `binding.pry` inside `it` block.
417-
418-
spec/features/hello_world_spec.rb <!-- .element: class="filename" -->
419-
420-
```ruby
421-
describe 'Your page', type: :feature do
422-
423-
before do
424-
visit(your_page_path)
425-
end
426-
427-
it 'Say hello' do
428-
click_button('Hello World')
429-
binding.pry
430-
expect(page).to have_content('Hello!')
431-
end
432-
end
433-
```

0 commit comments

Comments
 (0)