@@ -4,4 +4,86 @@ sidebar_position: 1
44
55# Introduction
66
7- Hello there
7+ Cuprite is a pure Ruby driver for [ Capybara] ( https://github.com/teamcapybara/capybara ) .
8+
9+ <img align="right"
10+ width="160" height="160"
11+ alt="Cuprite logo"
12+ src="https://raw.githubusercontent.com/rubycdp/cuprite/main/logo.svg?sanitize=true " />
13+
14+ It allows you to run Capybara tests on a headless Chrome or Chromium with _ no_
15+ Selenium/WebDriver/ChromeDriver dependency. Under the hood it uses
16+ [ Ferrum] ( /docs/ferrum/introduction ) , a high-level API to the browser over the
17+ [ CDP protocol] ( https://chromedevtools.github.io/devtools-protocol/ ) .
18+
19+ <br clear =" right " />
20+
21+ ## Installation
22+
23+ Download Chrome or Chromium from the official source for
24+ [ Chrome] ( https://www.google.com/chrome/ ) or [ Chromium] ( https://www.chromium.org/getting-involved/download-chromium ) .
25+ The binary should be in the ` PATH ` or ` BROWSER_PATH ` , or you can pass it with the
26+ ` :browser_path ` option, see [ Customization] ( /docs/cuprite/customization ) .
27+
28+ Add this to your ` Gemfile ` and run ` bundle install ` .
29+
30+ ``` ruby
31+ group :test do
32+ gem " cuprite"
33+ end
34+ ```
35+
36+ ## Quick Start
37+
38+ In your test setup add:
39+
40+ ``` ruby
41+ require " capybara/cuprite"
42+
43+ Capybara .javascript_driver = :cuprite
44+ Capybara .register_driver(:cuprite ) do |app |
45+ Capybara ::Cuprite ::Driver .new (app, window_size: [1200 , 800 ])
46+ end
47+ ```
48+
49+ Requiring ` capybara/cuprite ` already registers a ` :cuprite ` driver with default
50+ options, so you only need to register it yourself if you want to customize it.
51+
52+ Then write your tests as usual:
53+
54+ ``` ruby
55+ it " signs in" , js: true do
56+ visit " /login"
57+
58+ fill_in " Email" , with: " user@example.com"
59+ fill_in " Password" , with: " secret"
60+ click_button " Sign in"
61+
62+ expect(page).to have_content(" Welcome" )
63+ end
64+ ```
65+
66+ ## Docker
67+
68+ See [ Docker] ( /docs/cuprite/docker ) .
69+
70+ ## Ferrum under the hood
71+
72+ Since Cuprite is built on top of Ferrum there are many useful methods you can
73+ call even using this driver. ` page.driver.browser ` is a ` Ferrum::Browser `
74+ instance:
75+
76+ ``` ruby
77+ browser = page.driver.browser
78+ browser.mouse.move(x: 123 , y: 456 ).down.up
79+ browser.network.emulate_network_conditions(offline: true )
80+ ```
81+
82+ See [ Ferrum documentation] ( /docs/ferrum/introduction ) for the full API.
83+
84+ ## Migrating from Selenium
85+
86+ Check your code for ` page.driver.browser.manage ` calls, there's no ` manage ` in
87+ Cuprite. Use driver methods instead, for example
88+ [ cookies] ( /docs/cuprite/cookies ) or
89+ [ window resizing] ( /docs/cuprite/windows-frames ) .
0 commit comments