Selenium IDE test duration - selenium-ide

I was wondering how I can get an echo of the duration of a test.
I already got the time stamp at the beginning of the test and at the end, but for the reason of laziness it would be nice to get an echo displaying the time it took to run the test.

Here is the code that works on my side. It displays 5 sec duration (pause in test). Try it yourself:
<!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 profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="https://www.google.com.ua/" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>storeEval</td>
<td>{new Date()}</td>
<td>Cur_time</td>
</tr>
<tr>
<td>echo</td>
<td>${Cur_time}</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>5000</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>{new Date()}</td>
<td>Cur_time2</td>
</tr>
<tr>
<td>echo</td>
<td>${Cur_time2}</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>{(storedVars["Cur_time2"].getTime() - storedVars["Cur_time"].getTime())/1000}</td>
<td>diff</td>
</tr>
<tr>
<td>echo</td>
<td>${diff}</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>

storeEval is your friend here.
I'm assuming you have the start and end timestamps stored in variables, so you can storeEval end-start and echo the result

Related

Delete data using given data from a table

<?php
require_once("connection to server.php");
?>
<link rel="stylesheet" type="text/css" media="all" href="niceforms-default.css"">
<table>
<?php
error_reporting (0);
mysql_select_db("leave_db");
$mysql="SELECT * FROM users WHERE Username='$_POST[nameEdit]'";
$result=mysql_query($mysql);
while($row=mysql_fetch_array($result)){
?>
<thead>
<tr>
<table width="100%" id="rounded-corner" summary="2007 Major IT Companies' Profit">
<tbody>
<td></td>
<td width="40%"><?php echo $row['Fname'];?> <?php echo $row['Lname'];?></td>
<td width="10%"><?php echo $row['Sex'];?></td>
<td width="20%"><?php echo $row['Nationality'];?></td>
<td width="20%"><?php echo $row['Role'];?></td>
<td width="10%"><img src="images/trash.png" alt="" title="" border="0" /></td>
</tbody>
</table>
<?php
}
?>
<?php
mysql_close();
?>
<?php
require_once "config.php";
if (isset($_GET['id'])){
$id = $_GET['id'];
$del=mysql_query("DELETE FROM users WHERE UserID ='$id'");
if($del){
echo "<p><span style='font-weight:bold; color:#0000FF; margin-left:150px;'>Successfully deleted</span></p>"; header("Location:delete_user.php");
}
else
echo "<p><span style='font-weight:bold; color:#FF0000; margin-left:150px;'>An Error while deleting ".mysql_error()."</span></p>";
}
?>
</table>
<!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" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
that is my code and i want to delete data from my database it runs very well but does not delete data because i want to pick values that have been retrieved from the data base
Like
Name Username
Ian i234
so if one choses to delete using i234 it does not delete
You haven't included the code for delete_user.php.
I would also have a guess to say the following line is wrong:-
<td width="10%"><img src="images/trash.png" alt="" title="" border="0" /></td>
You can't just stick php inside html and expect it to work.
You will need to change it to the following.
<td width="10%"><img src="images/trash.png" alt="" title="" border="0" /></td>

spring mvc and freemarker - how to post a form ?

I am unsure about doing simple crud operation with spring and freemarker.This is what I tried to do.
springTag.ftl
<!DOCTYPE html>
<html xmlns:sec="http://www.springframework.org/security/tags" >
<head>
......
<#import "/spring.ftl" as spring />
..........
<head>
......
</head>
<body>
<#fragment.header/>
<form action="/listController/springTag" method="post" >
<#spring.bind "student" />
<table>
<tr>
<td>Name:</td>
<td><input path="student.name" /></td>
</tr>
<tr>
<td>Age:</td>
<td><input path="student.age" /></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Save Changes" />
</td>
</tr>
</table>
</form>
........................
</body>
How do I get the values in controller ? I have specified the model attribute as student . I am a newbee here . Can someone help ?
I found the answer.
<form action="/listController/springTag" method="post" >
<#spring.bind path= "student" />
<table>
<tr>
<td>Name:</td>
<td> <#spring.formInput "student.name" /> </td>
</tr>
<tr>
<td>Age:</td>
<td><#spring.formInput "student.age" />
<#spring.showErrors "student.age","error" /></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Save Changes" />
</td>
</tr>
</table>
</form>
This was the change I made.

How could i fill fields of pop up windows with Selenium?

I'm working with Selenium extension for Firefox trying to fill fields for one project of the university for Facebook but I can not access to a specific window (promote website) on a page created by me on that social network, because appears an error with the following message:
Element id = fbpage.... not found
I don't know if it's because this is a pop up window or something similar.
Someone knows how could I access to that kind of field?
I add the html code version:
<?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 profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="https://www.facebook.com/admgsproject" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>link=Facebook</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>link=Facebook</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=#navItem_811212168953432 > div > div.clearfix > a._5afe.sortableItem > div.linkWrap.noCount > span</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=#navItem_811212168953432 > div > div.clearfix > a._5afe.sortableItem > div.linkWrap.noCount > span</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=fbpage_invite_audience_action</td> //ERROR
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=fbpage_invite_audience_action</td> //ERROR
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[#id='u_jsonp_3_2']/div/ul/li[3]/a/span/span</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[#id='u_jsonp_3_2']/div/ul/li[3]/a/span/span</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
The part where i can not access is the html code that have invite_audience_action
Thank you in advance!
Have you looked into the selectWindow command?
https://saucelabs.com/resources/selenium-tips-working-with-multiple-windows

How to enter text in TinyMCE editor with Selenium IDE in firefox 14

I made a test which is working in newer or older firefox versions, slower or faster internet connection (at least I say that internet of my virtual machine in vmware is slow), but something and I don't know what causes a failure after typeKeys command in another computer. Somehow text is not written in the TinyMCE editor and therefore assertion fails.
Can anyone tell me what could cause such a thing or maybe there are incompatible commands?
<?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 profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://tinymce.com" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>http://tinymce.com/tryit</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>15000</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>id=demo_tab</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>id=content_ifr</td>
<td></td>
</tr>
<tr>
<td>selectFrame</td>
<td>id=content_ifr</td>
<td></td>
</tr>
<tr>
<td>focus</td>
<td>//body[#id='tinymce']</td>
<td></td>
</tr>
<tr>
<td>clickAt</td>
<td>//body[#id='tinymce']</td>
<td>(1,1)</td>
</tr>
<tr>
<td>typeKeys</td>
<td>//body[#id='tinymce']</td>
<td>writing something in this silly form</td>
</tr>
<tr>
<td>fireEvent</td>
<td>//body[#id='tinymce']</td>
<td>blur</td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>writing something</td>
<td></td>
</tr>
<tr>
<td>selectFrame</td>
<td>relative=parent</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>id=submitbtn</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=submitbtn</td>
<td></td>
</tr>
<tr>
<td>waitForTextPresent</td>
<td>Post dump</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>HTML output from post</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>writing something</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
Don't hesitate to ask if I wasn't clear enough.
Thanks for replies in advance.
Try using
Command | runScript
Target | tinyMCE.get('text_area_id_not_iframe_id').setContent('Your text')
Which will work on specific tinyMCE's or if you have multiple tinyMCEs on one page
Otherwise if you only have one tinyMCE, runScript | tinyMCE.activeEditor.setContent('Your text')
Here's what's working for me, essentially, by selecting the frame (others have suggested this), then the click and focus commands will make it the active editor, allowing the sendKeys command to work. In this example, I'm passing a variable to the editor as well as saving the iframe TinyMCE creates as a variable. For instances where multiple, I'm looping through them based on the ${frame} variable.
<
tr>
<td>selectWindow</td>
<td>null</td>
<td></td>
</tr>
<tr>
<td>selectFrame</td>
<td>xpath=//*[contains (#id, '${frame}')]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>xpath=//*[contains (#id, 'tinymce')]</td>
<td></td>
</tr>
<tr>
<td>focus</td>
<td>xpath=//*[contains (#id, 'tinymce')]</td>
<td></td>
</tr>
<tr>
<td>sendKeys</td>
<td>xpath=//*[contains (#id, 'tinymce')]</td>
<td>${date} ${frame}</td>
</tr>

Struts 2 select tag filled by list property

I am new to struts 2. I am facing problem in filling Select tag with list property. The values are supplied from action class.Please provide me sample sode for this scenario.
My action class
public class TripDetailsAdd extends ActionSupport {
#Override
public String execute() throws Exception {
return SUCCESS;
}
public String populate() {
VehicleDAO vehicleDAO = new VehicleDAO();
this.lstVehicles.addAll(vehicleDAO.getAllVehicles());
return "populate";
}
private String vehicleId;
private Collection lstVehicles = new ArrayList<VehiclesVO>();
}
Jsp page content:
<%# taglib prefix="s" uri="/struts-tags"%>
<%# taglib prefix="sform" uri="/struts-dojo-tags"%>
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%#page import="com.vms.business.dao.VehicleDAO"%>
<%#page import="java.util.Collection"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Trip Details</title>
</head>
<body>
<s:form action="tripDetailsAdd" method="POST" >
<s:hidden name="expenseTypeId"></s:hidden>
<table width="100%" height="96%" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><!-- Menu Starts --> <jsp:include
page="/pages/menu.jsp"></jsp:include> <!-- Menu End -->
<table width="95%" align="center">
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="highlight">Trip Details Add</td>
<td><s:actionerror /><s:actionmessage /></td>
</tr>
<tr>
<td class="header3shadow" colspan="2"><img height="2"
border="0" width="100%"></img></td>
</tr>
</table>
<table>
<tr>
<td> </td>
</tr>
</table>
<div
style="overflow: auto; height: expression((document.body.clientHeight -80) +px ');">
<table width="60%" cellspacing="0" cellpadding="0" border='0'>
<tr>
<td class="FieldTitle" valign="top">
<table width="100%" cellspacing="4" cellpadding="0" border='0'>
<s:select headerKey="0" headerValue="Select One" required="*" label="Vehicle No."
labelSeparator=":" list="lstVehicles" listKey="vehicleId" listValue="regNo"></s:select>
</td>
</tr>
<tr>
<td>
<table width="100%" cellspacing="4" cellpadding="0" border='0'>
<s:textfield labelposition="left" requiredposition="right"
name="totalIncome" label="Total Income" cssStyle="FieldTitle"
labelSeparator=":"></s:textfield>
</table>
</td>
</tr>
</table>
<table cellpadding="0" width="60%" cellspacing="0" border="0">
<tr>
<td align="right"><s:submit label="Add" value="Add"></s:submit></td>
</tr>
</table>
</div>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</s:form>
</body>
</html>
Mapping
<action name="*TripDetailsAdd" method="{1}"
class="com.vms.trip.presentation.TripDetailsAdd">
<result name="success" type="redirect">showTripDetailsList
</result>
<result name="populate">/pages/tripdetails/TripDetailsAdd.jsp
</result>
<result name="error">/pages/tripdetails/TripDetailsAdd.jsp
</result>
<result name="input">/pages/tripdetails/TripDetailsAdd.jsp
</result>
</action>
In this if i add Validation file or If any error occurs in page drop down is not loading.Please help me..
Struts2 select tag
<s:select label="Pets"
name="petIds"
list="petDao.pets"
listKey="id"
listValue="name"
value="%{petDao.pets.{id}}"
/>
In the above. value = default selection, list = collection (of Map) coming from your action class, listKey = Key for map, listValue = value for map.
Edit (after looking at provided code):
your problem is that you do not have any getter in action class that corresponds with lstVehicles (which is mentioned in list property of your select tag)
Add this to your action class:
public List getLstVehicles ()
{
return this.lstVehicles;
}