Unable to generate results with allure / ruby cucumber - ruby

I have been working on a new auto framework in ruby, but I am unable to get allure reporting results created, I have tried various different things but ultimately end up with the following errors:
DevTools listening on ws://127.0.0.1:12177/devtools/browser/498a65da-7ba2-4387-8243-8d0e5be0424e
WARNING: The formatter AllureCucumber::Formatter is using the deprecated formatter API which will be removed in v4.0 of Cucumber.
undefined method 'name' for #<Cucumber::Core::Test::Step:0x00000000059673a0> (No MethodError)
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/allure-cucumber-0.5.8/lib/allure-cucumber/formatter.rb:121:in 'after_test_step'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.0/lib/cucumber/formatter/ignore_missing_messages.rb:11:in 'method_missing'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.0/lib/cucumber/formatter/legacy_api/adapter.rb:32:in 'block in initialize'
I have followed the documentation and have good experience using the reporting with java, is it likely my version of cucumber is unsupported? At best I can get an empty results directory created but the cucumber tests always error out with the above message.

This post is 8 months old so hopefully you got it worked out, but incase anyone else lands here, you can patch the cucumber-ruby gem with the following to get your tests to pass:
class Cucumber::Core::Test::Step
def name
return text if self.text == 'Before hook'
return text if self.text == 'After hook'
"#{source.last.keyword}#{text}"
end
end
The warning about API depreciation past 4.0 will remain, though. Hopefully it will be fixed before then: https://github.com/allure-framework/allure-cucumber/issues/63

Related

Ruby-Watir Warning - Selenium::WebDriver::Error::ObsoleteElementError

Hey y'all I'm getting a warning running my watir test automation code and even though it works I want to address it.
The Warning: 2020-02-12 08:35:47 WARN Selenium [DEPRECATION]
Selenium::WebDriver::Error::ObsoleteElementError is deprecated. Use
Selenium::WebDriver::Error::StaleElementReferenceError (ensure the
driver supports W3C WebDriver specification) instead.
The offending line of code:
iframe.select(:id => 'col0').wait_until(&:present?)
from this larger snippet.
iframe = #b.iframe(:title => /Mass Delete/)
iframe.wait_until(&:present?)
if iframe.present?
iframe.link(:visible_text => /Mass Delete #{type}/).click
iframe.select(:id => 'col0').wait_until(&:present?)
iframe.option(:text => /Owner Alias/).select
iframe.option(:text => 'equals').select
iframe.text_field(:id => "fval0").set user
iframe.button(:title => "Search").click
else
raise "Unable to locate the Salesforce Iframe"
end
Here's the page html:
Page Html
I've tried using different locators to interact with that element but to no avail.
This will be addressed in the next version of Watir - exact release date is TBD. In the short-term, you have a couple of options to hide the warning.
Log to File
I would suggest sending the Selenium logs to a file. This keeps it separated and still available if you happen to need it.
Selenium::WebDriver.logger.output = 'selenium.log'
Ignore Warnings
Usually you do not need the Selenium warnings as they should get addressed by Watir changes. Therefore you could change the Selenium logger to ignore warnings:
Selenium::WebDriver.logger.level = :error

Getting undefined method when trying to use a ruby wrapper for the Spotify Web API

I was messing around with RSpotify which is a ruby wrapper for the Spotify API.
I added a form and sent the search result param to be looked up in the API but i'm getting the following error:
NoMethodError: undefined method `empty?' for nil:NilClass
from /Users/user/.rvm/gems/ruby-2.3.1/gems/rspotify-1.21.0/lib/rspotify/connection.rb:71:in `send_request'
I double checked and reinstalled the gem, added it to the gemfile and everything. I can't seem to figure out why it's not working.
Here's the code (It was working a few weeks ago when I wrote it):
post '/music' do
search = RSpotify::Artist.search(params[:search])
#artist = search.first
#image = #artist.images.first["url"]
#top_tracks = #artist.top_tracks(:US)
albums = #artist.albums
#titles = []
albums.each { |album| #titles << album.name }
#titles.uniq!
#related_artists = #artist.related_artists
erb :'/music/show'
end
You seem to be using an outdated version (1.21.0, judging by your output). The current version is 1.22.1 (see https://rubygems.org/gems/rspotify) => maybe try updating.
Also, like Jeff said: Apparently there's an open GitHub issue that says that this issue occurs when you're not properly authenticated. So maybe check that your credentials are 1) set and 2) still valid. A simple way to check your credentials is to simply use them with the API directly (see http://www.compciv.org/recipes/data/touring-the-spotify-api/) => if they don't work there, it's probably not the code but your credentials that aren't working properly.

Failed to run custom step with the selenium cucumber ruby

I am writing a test for desktop web automation using the
selenium cucumber ruby.
My test includes both predefined and custom steps.
However, my test fails to run due to an error caused by a custom step.
The feature file that I run:
Feature: Login a customer
Scenario: Go in a call
Given I navigate to <url>
...
When I submit the form with id "custSearchSimple"
....
And I wait for 5 sec
Then element having id "accNumber" should be present
The When I submit the form with id "custSearchSimple" is a custom step.
This step is defined in the custom_step.rb. I have used the submit command of the Selenium Cucumber Ruby API. The custom_step.rb is the following file:
require 'selenium-cucumber'
# Do Not Remove This File
# Add your custom steps here
# $driver is instance of webdriver use this instance to write your custom code
#firefox browser instantiation
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "https://localhost/telebet"
When(/^I submit the form with id "(.*?)"$/) do |arg1|
element= driver.submit(:id,"#{arg1}")
end
When I run the feature file by running cucumber features/name_of_the_file.feature, I get the NoMethodError error:
When I submit the form with id "custSearchSimple" # features/step_definitions/custom_steps.rb:12
private method `submit' called for #<Selenium::WebDriver::Driver:0x94c4bde4bdff4d6 browser=:firefox> (NoMethodError)
I could not find any example using the Selenium Cucumber Ruby API for writing custom steps. I suspect that I might have omitted some commands for the selenium web driver ruby. Something is missing that I could not find. Does anyone know why I get this error?
Maybe I am confused here but:
When(/^I submit the form with id "(.*?)"$/) do |arg1|
submit_form arg1
end
def submit_form(form_id)
submit("id", form_id)
end
Would do what you want? submit_form isn't a cucumber step, it's a ruby method - probably why you're getting Cucumber::UndefinedDynamicStep.

I18nData::NoTranslationAvailable -- countries-DE-CH: Can't access Spree admin, general settings, edit

Not sure what I changed to get this error when clicking on the Configuration tab in the Spree Admin panel. The spree_i18n gem contains the DE-CH.yml file and I wasn't getting any problems before. Nor is this happening on any other page.
codesi18n_data (0.4.1) lib/i18n_data/file_data_provider.rb
DATA_SEPARATOR = ";;"
extend self
def codes(type, language_code)
unless data = read_from_file(cache_file_for(type, language_code))
raise NoTranslationAvailable, "#{type}-#{language_code}"
end
data
end
def write_cache(provider)
Error is raised here: raise NoTranslationAvailable, "#{type}-#{language_code}"
I'm using spree 2-2-stable and spree_i18n 2-2-stable gems.
Thanks
Please see this issue. This is the exact problem you are encountering.

Why is mocha not stubbing this method in my Rails 3 integration test?

I have the following:
setup do
Capybara.current_driver = Capybara.javascript_driver
#project.user = #user
#project.save
Project.any_instance.stubs(:price_all)
end
And yet I have a test failing because the Project.price_all method is being run:
/Users/me/code/rails/myapp/app/models/project.rb:178:in `price_all'
This was working properly until I upgraded to Capybara 2 and the latest version of capybara-webkit.
Why is that method still being run? And how can I fix?
When you say "the Project.price_all method is being run", is that a typo, or is price_all really a class method? If it is indeed a class method, you'll want to use Project.stubs(:price_all) instead of including any_instance so the stub is directly on the Project class rather than an instance of Project. If that's not your issue, I'm not sure what else to suggest based on the code sample you've provided.

Resources