Why is Selenium only running the first test from my test suite? - selenium

I'm using Selenium stand alone server v2.3.0 on Windows XP (sp2). I'm noticing that when I try and run my html suite against Firefox, only the first test gets executed and then the Selenium Runner just sits there without doing anything. The command I use is
java -debug -jar c:/selenium/selenium-server-standalone-2.3.0.jar -port 4444 -userExtensions c:/selenium/user-extensions.js -htmlSuite *chrome http://www.stage.mycliusa.com c:/selenium/test/suite.html c:/selenium/report2.html
The HTML suite file contents are below. Interestingly, when I run the same command switching "*chrome" with "*iehta," everything runs fine. Any ideas why the Firefox tests are stopping after the first test? - Dave
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title>mycli USA Tests - Critical Path/Live/EX</title>
</head>
<body>
<table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium"><tbody>
<tr><td><b>mycli USA Tests - Critical Path/Live/EX</b></td></tr>
<tr><td>mycliConfigNewEXJourneyAWD</td></tr>
<tr><td>mycliContactRetailerOldEX</td></tr>
<tr><td>mycliRAQOldEX35Base</td></tr>
<tr><td>mycliPreApprovedEX35</td></tr>
<tr><td>mycliContactRetailerNewEX35AWD</td></tr>
<tr><td>mycliJMLHandraiserEX</td></tr>
<tr><td>mycliRABEBrochureEX</td></tr>
<tr><td>mycliContactRetailerNewEXJourneyAWD</td></tr>
<tr><td>mycliConfigNewEX35Base</td></tr>
<tr><td>mycliConfigNewEX35AWD</td></tr>
<tr><td>mycliRABMailEX</td></tr>
<tr><td>mycliContactRetailerNewEX35Base</td></tr>
<tr><td>mycliRABBothEX</td></tr>
<tr><td>mycliSATDEX</td></tr>
<tr><td>mycliConfigOldEX35</td></tr>
<tr><td>mycliContactRetailerNewEX35Journey</td></tr>
<tr><td>mycliConfigNewEXJourney</td></tr>
</tbody></table>
</body>
</html>

The problem turns out to be Selenium (using the -htmlSuite option) isn't able to properly process files without an ".html" extension. When I renamed the files and ran the tests again, they sailed right through. This bug is documented here -- http://code.google.com/p/selenium/issues/detail?id=1208.

First function starting with "test"+fucntionName will work and so call all functions within it like
this.f1();
this.f2()
Inside that function !

Related

Trouble displaying test results in browser with Mocha, Chai, and webdriver.io

I am using Webdriver.io with Mocha and Chai. I've written several tests that work great from the command line. It opens the Chrome browser, runs the tests, and displays the resultsin the command line. However I am having issues getting the results of the tests to display in the browser view (have a presentation that I would like to show the tests in the browser view). I'm using the mocha html template for viewing tests in the browser, but it only displays "passes: 0failures: 0duration: 0s" in the upper right. I've copied the html file to the first file in my testing structure and changed the paths to the js and css files. I don't see anything in here that references webdriver.io, is that the missing piece?
<!DOCTYPE html>
<html>
<head>
<title>Mocha</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="./node_modules/mocha/mocha.js"></script>
<script src="./node_modules/chai/chai.js"></script>
<script>mocha.setup('bdd');</script>
<script src="./test/specs/createNewProduct.js"></script>
<script>
mocha.run();
</script>
</body>
</html>
I'm opening the file by right clicking on it and opening with Chrome.
Hi I am not clear understand what you want to achieve. But have look to https://github.com/webdriverio-boneyard/wdio-allure-reporter
It is generate beautiful reports for wdio

ELM : Compile ELM page to JS

after creating an ELM page and running it successfully using (elm-reactor),
I have compiled it to generate the js file and open it using browser.
using the following command : elm-make pageName.elm --output target.js.
anyway the target.js page is generated successfully but when opening it using the browser it does not show the desired outcome instead it displays the source code as per the below screen shot
Run elm-make pageName.elm without --output target.js and open produced index.html
Alternatively, create your own *.html file and embed target.js via <script> tag, as you would normally do it for any other JavaScript files:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My app</title>
<script src="target.js"></script>
<script>
// Run the application manually.
Elm.Target.fullscreen();
<script>
</head>
<body>
</body>
</html>
Assuming that the name of the entry module is Target and you want it to take over the whole page.

File upload with Behat, Mink & PhantomJS

I am trying to upload a file using Behat. Therefore I wrote this simple HTML page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file" /><br />
<input type="submit" />
</form>
</body>
</html>
and a simple Behat feature:
Feature: test
Scenario: Some Test
Given I am on "/upload.php"
And I attach the file "/path/to/tile" to "file"
When the I attach the file ... to ... phrase is executed, the selenium 2 driver generates a curl request and sends it to PhantomJS: http://localhost:4444/wd/hub/session/5b9a8630-ed8e-11e4-956f-956a9ce75127/element/:wdc:1430215640681/value with params: {"value":["\/path\/to\/file"]}
The request does not terminate unless aborting it and PhantomJS does not react on the request in any way.
I already searched through the net and found several threads saying that it does work and several saying that does not work including an issue on github (https://github.com/detro/ghostdriver/issues/282) which was closed and reopend multiple times.
Versions:
PhantomJS: 2.0.0
Behat: 3.0.15
Mink: 1.6.1
Mink-Selenium2-Driver: 1.2.0
Does anyone know a working solution for this problem?
Could this behaviour exist due to inability to upload files that is a known bug with PhantomJS v 2.0.0?
Basically, a change made in Qt 4.8 and incorporated subsequently in Qt 5.0 prevented clicking on file input elements that were not caused by user gestures.
The solution is discussed further in the issue thread.
To quote, you have to comment one if condition in
/src/qt/qtwebkit/Source/WebCore/html/FileInputType.cpp
//if (!ScriptController::processingUserGesture())
// return;
then compile the binary.

internet explorer, modernizr.js, respond.js, html5shiv.js, ie-7.js compatibility

I have updated my code to latest Twitter Bootstrap v3, and it has dropped support for older (ie7 or less) browsers, even ie8 / ie9 are not fully supported, so I am trying to use some third party plugin / scripts so I don't have to write IE specific css unless it's critical or necessary (not worried about css3 shadows, rounded corners etc).
modernizr.js I will be using this,
respond.js (I think I will be using it as well for media queries support in older browsers)
now tell me if modernizr.js and respond.js can work together
also
I think *html5shiv.js is not required as modernizr.js covers it (tell me if it does)? and also can I load alongside respond.js if modernizr.js doesn't provide html5 enhancement?
tell me if I still need to use ie9.js? if yes with which combination?
As I want
a) Media queries support
b) Browser detection for css3 features support (which modernizr.js does well)
c) Would like my website(s) to work in IE browsers (not worried about shadows, rounded corners etc, just bug's layout, float, etc)
so help me with this situation, oh and I also use
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en-US"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en-US"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<!--<html class="js">-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
so tell me I need to do something with these as well to achieve my desired result (specially chrome-1 should I be using it?
Thanks
*UPDATE:*
Since I asked this question, I am using this approach, I am using custom modernizr build without html5shiv, and I dropped ie7.js tried ie9.js same results (found it v. buggy instead of helping was causing issues), using respond.js and separate html5shiv and it has been working for me fine since.
Now I also use this tag,
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
dropped chrome=1

Selenium IDE - best way to not repeat actions that are common for all test cases

For all my Selenium IDE TCs I have a common step of logging in using username, password and logging out at the end for each TC.
The best way I can think of is
creating the user id, password, base url as variables in a common file. That way I don't have to repeat the steps common for all test cases and if the user ID or base url change - I dont have to modify each and every TC.
Was also looking at robot framework to solve this but could not figure it.
Thanks
creating the user id, password, base url as variables in a common file
You are totally right! Also you can create separate files for actions that will be repeated ("methods") and organize them into different folders. Then compose different test suites with these files (use relative paths like ../../../../). In test suite folder you can store file with variables that concern only this test suite and test suite file itself.
For example, create Authentication folder with Login.html, Logout.html test cases. Test suite will be look something like that:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title>Test Suite</title>
</head>
<body>
<table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium"><tbody>
<tr><td><b>Test Suite</b></td></tr>
<tr><td>StoredVariables</td></tr>
<tr><td>Login</td></tr>
...
<tr><td>SomeActions</td></tr>
...
<tr><td>Logout</td></tr>
</tbody></table>
</body>
</html>
Variables will live during all test suite.
It seems you might be better off with Selenium RC or Selenium 2 (WebDriver) which will allow you to have an initialise to setup id, password and setup files? A few examples are shown in this post which I came across earlier: Selenium Test - preserve session across multiple test runs
Sorry if these are things you already knew :)