Skip to content

Commit 2cb026c

Browse files
authored
Feature | [Automation workshop] Add URL, Path helpers (#210)
* Add Routes, credentials, rest * Practice rep add * Change RSpec slides * Add URL and Path helpers slides * Fixed repositories * Change ruby version * Add Circle, rubocop and change capybara slides
1 parent 87d8661 commit 2cb026c

File tree

7 files changed

+466
-54
lines changed

7 files changed

+466
-54
lines changed

index.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ title: Ruby presentations
5050
<br>
5151
<small>Learn how to do refactoring in Ruby.</small> -->
5252

53+
- [Refactoring](/slides/refactoring-ruby)
54+
<br>
55+
<small>Clean code is code that is easy to read, understand and maintain. </small>
5356

5457
- [Rack](/slides/rack)
5558
<br>

slides/automation-qa/capybara.markdown

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The first thing we need to do is add our gem to Gemfile in `:test` group
3030
group :test do
3131
gem "capybara"
3232
gem "rspec-rails"
33+
gem "selenium-webdriver" # in order to use Selenium
3334
end
3435
```
3536

@@ -106,6 +107,12 @@ spec/feature/test_spec.rb <!-- .element: class="filename" -->
106107
visit('/') # Capybara will visit `http://www.google.com`
107108
```
108109

110+
--
111+
112+
## Launch different browsers
113+
114+
115+
109116
---
110117

111118
# Drivers
@@ -236,7 +243,7 @@ all('a', text: 'Home')
236243
all('a#person_123')
237244
```
238245

239-
More about different types of finder you can find [here](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara/Node/Finders)
246+
More about different types of finder you can find [here](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara/Node/Finders) and [here](https://gist.github.com/tomas-stefano/6652111)
240247

241248
--
242249

@@ -267,8 +274,6 @@ When you trying to find an element, it is common to have two or more matches whi
267274
Capybara comes with a very intuitive DSL which is used to express actions that will be executed. This is the list of basic command that are used
268275

269276
```ruby
270-
visit('page_url') # navigate to page
271-
272277
click_link('id_of_link') # click link by id
273278
click_link('link_name') # click link by link text
274279
click_button('button_text') # click button by button text
@@ -296,6 +301,35 @@ end
296301

297302
--
298303

304+
## `Visit`
305+
306+
Visit method allows you navigate to the given [**URL**](https://rubygarage.github.io/slides/qa-automation/rails-structure#/9/5) or [**Path**](https://rubygarage.github.io/slides/qa-automation/rails-structure#/9/5) Helpers
307+
308+
```ruby
309+
visit("/users") # navigate to page with users through URL
310+
311+
visit(users_path) # navigate to page with users through Path
312+
313+
# In both cases we will visit page with users (https://your_facebook/users)
314+
```
315+
316+
Also you can provide params for visit method
317+
318+
```bash
319+
user.id
320+
=> 1
321+
```
322+
323+
```ruby
324+
visit("/users/#{user}") # navigate to page with user through URL
325+
326+
visit(user_path(user)) # navigate to page with user through Path
327+
328+
# In both cases we will visit page with user_id = 1 (https://your_facebook/users/1)
329+
```
330+
331+
--
332+
299333
### Advanced `DSL`
300334

301335
For scenarios where basic the DSL cannot help, we use xpath and CSS selectors (CSS selectors will be used by default). This is very common, since modern web applications usually have a lot of JavaScript code that generates HTML elements with attributes that have generated values (like random ids, etc.)
@@ -339,6 +373,12 @@ expect(page).to have_selector(:xpath, './/table/tr')
339373
expect(page).to have_xpath('.//table/tr')
340374
expect(page).to have_css('table tr.foo')
341375
expect(page).to have_content('foo')
376+
expect(page).to have_no_content('foo')
377+
expect(page).to have_current_path(your_path)
378+
expect(page).to have_link("Foo", :href=>"googl.com")
379+
expect(page).to have_no_link("Foo", :href=>"google.com")
380+
expect(page).to have_field('#field')
381+
expect(page).to have_button('#submit')
342382
```
343383

344384
---
@@ -365,4 +405,29 @@ Finally, in drivers that support it, you can save a screenshot:
365405
save_and_open_screenshot
366406
```
367407

368-
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`.
408+
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+
```

slides/automation-qa/factory-bot.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ group :test do
1919
end
2020
```
2121

22-
Then, run `bundle` to download and instal new gem
22+
Then, run `bundle install` to download and instal new gem
2323

2424
```bash
2525
$ bundle install

slides/automation-qa/index.markdown

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,12 @@ title: QA Automation
4040

4141
- [SimpleCov](simple-cov)
4242
<br>
43-
<small>How to check coverage in RSpec? What is SimpleCov? </small>
43+
<small>How to check coverage in RSpec? What is SimpleCov? </small>
44+
45+
- [Rubocop](rubocop)
46+
<br>
47+
<small>What is Rubocop? How it use? </small>
48+
49+
- [CircleCI](../circleci)
50+
<br>
51+
<small>CircleCI is Continuous Integration, for testing apps, which is fast, functional and flexible. </small>

0 commit comments

Comments
 (0)