trying to get simple poltergeist example running - poltergeist

I was playing around with selenium via rspec but was dissatisfied and I saw recommendations for poltergeist. When I try to run it with my tests, it seems like the poltergeist driver doesn't show up where it should. I was a little confused where rack test fits in with poltergeist but I tried many different things. I then found this simple example and tried to get that to work but still no luck. I am using jruby on windows.
I am using the example found here: https://gist.github.com/pzol/1607842
I moved all my code into one file, there is no spec helper for this case
I did install phantomjs and ran a little hello world example for phantomjs and it is in my path
require 'rspec'
require 'capybara/rspec'
require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, debug: true)
end
describe 'poltergeist', :type => :request, :js => true do
it 'should find github poltergeist in google' do
visit 'http://www.google.com/'
fill_in "q", :with => "github poltergeist"
click_button "btnK"
page.should have_content 'jonleighton/poltergeist'
end
end
jruby -S rspec poltergeist-test2.rb
F
Failures:
1) poltergeist should find github poltergeist in google
Failure/Error: visit 'http://www.google.com/'
NoMethodError:
undefined method visit' for #<RSpec::Core::ExampleGroup::Nested_1:0x4324
4fd9>
# ./poltergeist-test2.rb:18:in(root)'
Finished in 0.01 seconds
1 example, 1 failure
Failed examples:
rspec ./poltergeist-test2.rb:17 # poltergeist should find github poltergeist in
google

hmmm, well I was looking at capybara docs some more and I changed this line:
describe 'poltergeist', :type => :request, :js => true do
to this line, where I made :type to be :feature and now it seems to be ok ..
describe 'poltergeist', :type => :feature, :js => true do
Seems in my google searches the other day I saw something on that but wasn't sure and at the moment I am not clear what the difference is but I am making progress it appears

Related

What's the normal procedure for finding the name of the necessary ESLint package based on the config name given in the error message?

I was just struggling with the error below in my IDE for a frustratingly-long time:
ESLint: Error: Failed to load config "#vue/typescript" to extend from.
After a lot of Googling and running commands I found online, I eventually found that what (seemed to) fix the problem was running this:
yarn add -D #vue/eslint-config-typescript
My question is: How was I supposed to figure that out? Is there some website or service or something where I could have searched for #vue/typescript and found out that the package I needed to install was #vue/eslint-config-typescript?
Ok, I figured it out: in the ESLint docs, it says that basically that the part after the forward-slash should be understood to always start with eslint-plugin:
They show the following examples:
"plugins": [
"jquery", // means eslint-plugin-jquery
"#jquery/jquery", // means #jquery/eslint-plugin-jquery
"#foobar" // means #foobar/eslint-plugin
]

Angular/Jasmine: $httpBackend.expectGET works on Mac, not on Linux

I have the following setup to test a directive:
beforeEach(inject(function($compile, $rootScope, $injector) {
$httpBackend = $injector.get('$httpBackend');
var html = '<password-strength-bar password-to-check="password"></password-strength-bar>';
scope = $rootScope.$new();
elm = angular.element(html);
$compile(elm)(scope);
$httpBackend.expectGET('l10n/en.js').respond({});
$httpBackend.expectGET('tpl/page_signin.html').respond({});
}));
This works fine on a Mac. However, when I run the same code on Linux, it fails with the following error. It is a headless Linux box, but I'm using PhantomJS as my "browsers" in karma.conf.js.
Error: Unsatisfied requests: GET tpl/page_signin.html
I verified that both operating systems are using the same version of Node.
On a similar note, I've installed Chrome and Xfvb (via Jenkins) to run my e2e tests driven by Protractor. The following works fine when running on my Mac locally, but fails on Linux.
it('should render signup when user clicks on "Create one" link', function () {
var signupLink = element(by.linkText('Create one'));
expect(signupLink.isDisplayed()).toBe(true);
signupLink.click();
expect(element.all(by.css('.wrapper')).first().getText()).
toMatch(/Hi there, we're so glad you're here./);
In Jenkins (on Linux), the error is:
Failures:
1) account signup should render signup when user clicks on "Create one" link
Message:
[31m Expected '' to match /Hi there, we're so glad you're here./.[0m
Stack:
Error: Failed expectation
at Object.<anonymous> (/var/lib/jenkins/jobs/myapp/workspace/tests/e2e/account.js:27:17)
at runMicrotasksCallback (node.js:337:7)
Any idea why tests would run fine on Mac, but not on Linux?
This turned out to be caused by using by.linkText('Create one') for my Protractor test. Once I added an id to the link and used by.id('create-account'), it worked.
I also found that using $('.alert') or by.css('alert') doesn't work nearly as well as by.id. Particularly when you click on a button and wait for something to appear on the next screen. For example:
var alert = element(by.id('success'));
browser.driver.wait(protractor.until.elementIsVisible(alert));

Watir and Rspec script does nothing

I am new new in Watir, Rspec testing and i am just getting familiar with it. I found one test on internet, combination of Rspec and watir but id does nothing. it throws error require 'spec' does not exist. I have rspec 2.12 installed. Did I miss something here, do i need to install something? Rspec scripts are working as well as watir but this combination not.
require 'watir'
require 'spec'
describe "Google" do
before :all do
#browser = Watir::Browser.new
#browser.goto "http://google.com"
end
it "has word 'Google' on main page" do
#browser.text.should include("Google")
end
it "has word 'Bing' as it's title" do
#browser.title.should == "Bing"
end
after :all do
#browser.close
end
end
"I found one test on internet" does not help. Please provide link to the page.
Also, you did not say how you run the script. As far as I remember, to run RSpec 1.x scripts you had to do spec file_name.rb, and with RSpec 2.x you have to do rspec file_name.rb. That could be the problem.

Does Firefox disable plugins that failed to initialize?

I am trying to test a Mozilla plugin (developed using FireBreath) in the form of an .so shared object file. The plugin was developed on Ubuntu, where it works fine.
I am now trying it under OpenSUSE - so I first symlinked the .so file in ~/.mozilla/plugins:
> ln -s /path/to/npXXX.so ~/.mozilla/plugins/
... and then ran Firefox (7) from command line:
> /path/to/firefox -P myprofile
...
LoadPlugin: failed to initialize shared library libXext.so [libXext.so: cannot open shared object file: No such file or directory]
LoadPlugin: failed to initialize shared library /path/to/npXXX.so [/path/to/npXXX.so: undefined symbol: gtk_widget_get_mapped]
# and the LoadPlugin messages do NOT show a second time - probably because plugin is disabled (via about:addons).
And so I thought to try different stuff to look into this - but first, I restarted Firefox, and realized that on the second run I do not get the "LoadPlugin: failed to initialize" messages anymore! Then I tried removing the plugins symlink, and restarting FF; and adding it again, and restarting FF - still no error messages!
So, this tells me that probably Firefox somehow disabled/blacklisted the plugin (but which one: libXext, npXXX or both?) , but searching (grepping) for (np)XXX in '/path/to/myprofile/blocklist.xml' returns nothing (the plugin should use a email-like id, not those number GUIDs, so I'd expect that string to show in blocklist.xml if it's there).
Does anyone know: is the default behavior of Firefox to disable/blocklist plugins, that fail to load at first? If so, is there a way to force Firefox to load them again (and spit out error messages)? If you'd also have links to where this behavior is documented, it will be much appreciated :)
Many thanks in advance for any answers,
Cheers!
Note: after I stopped seeing the error messages, I did the following:
I am trying "about:plugins": "No enabled plugins found";
then trying "about:addons", and clicking under Plugins: "You don't have any add-ons of this type installed";
This plugin is not embedded in an extension, so nothing new should be added in "about:addons" under "Extensions" - and as expected, nothing new shows there. Under Ubuntu (where all works), just by symlinking the plugin to ~/.mozilla/plugins, the above two locations/screens start showing the plugin info.
This one of the things that puzzle me - if it just showed the plugin as "disabled", maybe I would have had a chance to re-enable it again (to get a new batch of error messages) - however, "about:plugins" and "about:addons" simply show nothing - so there's nothing I can use to enable from there. Which tells me Firefox has used a different method to disable the plugin(s) - but I cannot tell what it is...
Firefox has a cache for XPCOM modules ("fastload cache"), if a module fails to load Firefox won't try again. The cache is reset automatically if an extension is installed or if the application is updated. Starting with Firefox 4 you can also use -purgecaches command line flag to discard the cache.

My cuke4duke tests hang and never terminate

I can't work out why my web based cucumber tests never terminate. All step definitions pass but the browser never exit on the last step and therefore my script is hanging.
I'm currently running cuke4duke (0.4.3), Geb(0.5.1), maven(2.2.1), selenium-firefox-driver/selenium-chrome-driver (2.0a6 and a7)
I've tested my scripts in Chrome and Firefox (3.6) / Windows XP and Ubuntu without any success.
Here is the output from my maven build
[INFO] Scenario: Navigate from homepage # features/helppage.feature:7
[INFO] Given I am on the homepage # Helppage$_run_closure1#f93ee4
[INFO] When I click on the about page # Helppage$_run_closure2#1c87031
[INFO] Then the title should display "About Google" # Helppage$_run_closure3#1f784d7
[INFO]
[INFO] 1 scenario (1 passed)
[INFO] 3 steps (3 passed)
[INFO] 0m5.421s
HANGING HERE
Env.groovy
import geb.Browser
import org.openqa.selenium.chrome.ChromeDriver;
this.metaClass.mixin(cuke4duke.GroovyDsl)
Before() {
new Browser(new ChromeDriver(),'http://www.google.com')
}
After() {
clearCookies()
}
helppage.groovy
this.metaClass.mixin(cuke4duke.GroovyDsl)
Given (~/I am on the homepage/) {
go('/')
}
When (~/I click on the about page/) {
go('/intl/en/about.html')
}
Then (~/the title should display "(.*)"/) { pageTitle ->
assert title == pageTitle
}
I'm not able to work out if the problem is in webdriver or in the cuke4duke distribution or anywhere else. I'm also not sure how I can add more debugging to the maven build in order to find out what is going wrong.
I think you need to call quit() on the Browser (you'll probably need to save a handle to it in your Before() hook).
I don't have time to test it for sure - we've moved from cuke4duke to cucumber-groovy, but I think it's actually a Geb Browser issue you're seeing here.
Have you tried running it without cuke4duke?
I found cuke4duke quite interesting but decided to even drop JRuby (not sure if you are using that) and go with a straight ruby installation, which is faster and more reliable.
Try updating to the latest jRuby (1.6.0). Might be related to this issue: Cucumber 0.4.3 (cuke4duke) with java + maven gem issues

Resources