You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
visit('/') # Capybara will visit `http://www.google.com`
107
108
```
108
109
110
+
--
111
+
112
+
## Launch different browsers
113
+
114
+
115
+
109
116
---
110
117
111
118
# Drivers
@@ -236,7 +243,7 @@ all('a', text: 'Home')
236
243
all('a#person_123')
237
244
```
238
245
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)
240
247
241
248
--
242
249
@@ -267,8 +274,6 @@ When you trying to find an element, it is common to have two or more matches whi
267
274
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
268
275
269
276
```ruby
270
-
visit('page_url') # navigate to page
271
-
272
277
click_link('id_of_link') # click link by id
273
278
click_link('link_name') # click link by link text
274
279
click_button('button_text') # click button by button text
@@ -296,6 +301,35 @@ end
296
301
297
302
--
298
303
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
+
299
333
### Advanced `DSL`
300
334
301
335
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.)
@@ -365,4 +405,29 @@ Finally, in drivers that support it, you can save a screenshot:
365
405
save_and_open_screenshot
366
406
```
367
407
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.
0 commit comments