Behat / Mink Opens Blank Page in Browser - bdd

I'm using Behat and Mink on Ubuntu for BDD. I've three steps in my feature:
Given I am on "/control.php"
And I wait for "3000"
Then print last response
If I do not include the #javascript tag, the test completes successfully and prints the correct HTML.
If I include the #javascript tag, the web browser (firefox) opens to a blank tab and Behat prints three blank lines instead of the actual HTML.
Any idea what might be causing this?

In this instance, I found that an error in the javascript caused the browser to alert a notice (visible in console). This notice caused Behat / Mink to trip and end execution. Hope this is helpful!

Related

Ruby - Form doesn't submit to the right page in Selenium-Webdriver

I am attempting to write some automated tests for a client my company has been working for. One of these tests is to have Selenium-WebDriver enter a username and password and login. When I do that manually as a human user, I get redirected to the right page (the base url page) and get logged in successfully. However, if I have Selenium-WebDriver do it, the page gets redirected to /users/:id and a 404 error occurs.
I have pasted the code in its most basic form below. I think the issue is due to page redirects but I can't be sure. (This is a rails project, the automated test is external.) I have tried adding delays, I've tried adding waits, and I've even tried slowing WebDriver down to solve this issue. Nothing seems to work. I don't know how to add a wait directly into the click function of the submit button. If anyone has any further ideas, that would be great.
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome
driver.navigate.to ''
driver.find_element(:id, 'user_email').send_keys ''
driver.find_element(:id, 'user_password').send_keys ''
driver.find_element(:name, 'commit').click
sleep 5 # this is so my eyes have time to see if it worked
driver.quit
Thanks in advance!
It looks like it's a browser thing. It works in some browsers, but not others.
Thank you for your thoughts!

Getting [error] Element css=input.logon_button.logon_button_hover not found in Selenium IDE

I am using Selenium IDE 2.9.0 firefox addon
Trying automate the URL testing
But I get the following error when I try to automate the login,
[error] Element css=input.logon_button.logon_button_hover not found
Looks to me like it's a variable element. The hover part may only show while you are hovering over the link, which you won't be when selenium is running. Rather that right clicking and using the command, or selecting from selenium, view the html for your page and find the element in the code while you aren't hovering over it, to ensure it isn't different.

Timeout error while using watir webdriver with Ruby

I am new to watir webdriver with ruby and I am trying out a few examples. I am getting a timeout error "Net::ReadTimeout: Net::ReadTimeout" for the following code -
b = Watir::Browser.new
b.goto "http://www.quora.com"
b.text_field(:name => 'email').set 'someone#gmail.com'
b.text_field(:name => 'password').set 'somepassword'
b.button(:class => 'submit_button').click
When I run the above code in console, firefox gets launched and quora main page comes up. But after that it doesn't do anything until it times out. I inspected the elements for username and password and they are right.
I ran the same code for gmail.com with the corresponding fields and it runs just fine.
Can someone please help?
Ameya
This is a known issue with quora.com.
Currently I'm not aware of any solutions, one possibility is to disable JavaScript when you login, but in this case you can't do much else after login. Maybe you can create a ticket in Selenium issue tracker.
See similar questions asked before.
Selenium code doesn't terminate
Why am I not able to login to Quora using an automation package like Selenium or Watir?
How to add JS on a page when it has been turned off initially by Selenium?
Is Selenium slow, or is my code wrong?

Test website by iterating every page and report which page produces error

Is there a plugin/extension/gem that iterates every page in a Rails app/website, to see if it renders properly, and returns a report with errors? Or am I over testing?
it seems what you are looking for is a smoke test gem, just google it and find whether that is something suite your need. And i find one here.
https://techblog.livingsocial.com/blog/2013/09/19/smokescreen-smoke-tests-for-ruby/

How can step through an Action that is requested from JavaScript during execution?

There is this one action that is requested using javascript during the loading of a page, it takes over 25 seconds to resolve. Looking at the code makes me think there is a scaling issue, but I am wondering if there is any way I can step through the code during the request so I can see what is happening. I try clicking 'debug/start debugging' but it won't launch the proper URL (access to the site is subdomain based), and it will also not find certain dependencies. I am able to browse the site directly via URL locally after mapping a URL via my hosts file to localhost (127...) but the default url that pops up (localhost...) from debug does not work because it is not formatted properly.
Any ideas?
You can attach the debugger to your browser by selecting "Attach to process" under "Debug" menu.
In the past, at least with ASP.NET we have used tracing to debug issues. You will just need to enable it in the webconfig. If you use warn, the messages will show in red and be easier to spot.

Resources