capybara

How to get “console.log” from Selenium (with Chrome) in the Rails log files?

五迷三道 提交于 2020-07-31 04:53:11
问题 In Rails project, I'm using Cucumber, with Capybara, in order to run my tests in a Chrome web browser through Selenium. My tests are running fine but I would like to get the console.log , console.error and so on in the log files of my Rails application. I have registered a :chrome capybara driver like this (based on different articles and SO answers): Capybara.register_driver :chrome do |app| capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( chromeOptions: { args: chrome

How to take a screenshot of a full browser page and its elements using selenium-webdriver/capybara in Ruby?

强颜欢笑 提交于 2020-07-18 10:43:06
问题 I am working on screenshot automation. In particular, I am trying to achieve the following: Prompt the user for the links to different pages on the website X Prompt the user for the class name Y I should be able to visit a website X login page, provide login details (assume they are known), click on "submit" button, that should redirect me to the "home" page Then I look at the list of links, provided by the user, visit each page and take screenshots of all elements, that have class Y (or the

Emulating a clipboard copy/paste with Selinum + Capybara

拈花ヽ惹草 提交于 2020-06-27 09:44:20
问题 I have a "Copy Link" button in my frontend UI. When clicked, the URL inside an input box is copied to the user's clipboard with this JS: const copyTextarea = document.querySelector("#copy-link-button"); copyTextarea.focus(); copyTextarea.select(); document.execCommand('copy'); When I try it out locally, this functionality works perfectly so I know the feature itself is working correctly. However I'm unable to test the copy with Capybara. I know from this post that Capybara does not provide a

Capybara with headless chrome doesn't clear session between test cases which use different subdomains

跟風遠走 提交于 2020-06-16 20:51:52
问题 I switched my rails tests from capybara-webkit to headless chrome. When I run a test which visits not the default Capybara host the first case passes but the second one fails because the user are already logged in when they try to login I use chromedriver v2.45 , selenium-webdriver (3.141.0) and capybara (2.18.0) I have the following setup: require 'selenium-webdriver' Capybara.register_driver :chrome do |app| options = Selenium::WebDriver::Chrome::Options.new( args: %w[headless disable-gpu

Capybara with headless chrome doesn't clear session between test cases which use different subdomains

本小妞迷上赌 提交于 2020-06-16 20:50:08
问题 I switched my rails tests from capybara-webkit to headless chrome. When I run a test which visits not the default Capybara host the first case passes but the second one fails because the user are already logged in when they try to login I use chromedriver v2.45 , selenium-webdriver (3.141.0) and capybara (2.18.0) I have the following setup: require 'selenium-webdriver' Capybara.register_driver :chrome do |app| options = Selenium::WebDriver::Chrome::Options.new( args: %w[headless disable-gpu

Basic browser authentication with Safari Capybara Selenium

陌路散爱 提交于 2020-05-28 07:53:39
问题 I've got a problem with browser authentication on Safari using Capybara/Selenium. I'm using this code to authenticate: visit "https://#{ENV['AUTH_USERNAME']}:#{ENV['AUTH_PASSWORD']}@my-staging-app.heroku.com" This works just fine on Chrome and FF but not on Safari. Any ideas how to bypass this? 回答1: Okey, I've found the solution for this. I had to use reversed proxy using e.g. Nginx and send proper headers :) Here is how I've done it: In this example I'll be using creds login: admin and

Basic browser authentication with Safari Capybara Selenium

巧了我就是萌 提交于 2020-05-28 07:53:21
问题 I've got a problem with browser authentication on Safari using Capybara/Selenium. I'm using this code to authenticate: visit "https://#{ENV['AUTH_USERNAME']}:#{ENV['AUTH_PASSWORD']}@my-staging-app.heroku.com" This works just fine on Chrome and FF but not on Safari. Any ideas how to bypass this? 回答1: Okey, I've found the solution for this. I had to use reversed proxy using e.g. Nginx and send proper headers :) Here is how I've done it: In this example I'll be using creds login: admin and

How can I block external connections with RSpec & Capybara?

僤鯓⒐⒋嵵緔 提交于 2020-05-26 13:40:31
问题 With my Rails project, I would like to write tests non-ideal conditions such as lack of internet connection or timeouts. For example, I am using a gem to contact an API and would like to make sure that I handle the error correctly if there is a connection issue between my app and the external API. I can do this already by making a fixture with VCR and removing the response from the "cassette". However, this has drawbacks: It has to be done manually. The cassettes can not be gitignored if I am

How can I block external connections with RSpec & Capybara?

孤者浪人 提交于 2020-05-26 13:38:48
问题 With my Rails project, I would like to write tests non-ideal conditions such as lack of internet connection or timeouts. For example, I am using a gem to contact an API and would like to make sure that I handle the error correctly if there is a connection issue between my app and the external API. I can do this already by making a fixture with VCR and removing the response from the "cassette". However, this has drawbacks: It has to be done manually. The cassettes can not be gitignored if I am

Upgrade old project to capybara

旧巷老猫 提交于 2020-04-21 13:35:29
问题 We are working right now with Ruby, Cucumber and Selenium to perform our integration tests. Right now we want to improve the quality of our tests and therefore we want to use Capybara. Now since all our methods need to be rewritten for that, we thought maybe someone has already done that and wrote a wrapper for the selenium webdriver, where Capybara does the job. For example: The wrapper should replace the following: driver.navigate_to "/home" to something like visit "/home" The point is, we