2. Save the output to a local file go-pear.php on your php installation folder.
2. Then run:
php go-pear.php
php go-pear.php
php PEAR/go-pear.phar4. Follow the instructions, and ignore the additional offerings to configure itpear channel-discover pear.phpunit.depear install phpunit/PHPUnit6. Download Selenium PHP PEAR extension and place into your PHP directorypear install Testing_Selenium-0.4.3.tar8. Download the sample GoogleTest and assuming you put it in C:\Tests folderphpunit --verbose GoogleTest C:/Tests/GoogleTest.php10. Remember the class name GoogleTest must be the same as the class name defined in the GoogleTest.php<?xml version="1.0" encoding="UTF-8"?>
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:if test="system-property('xsl:vendor')='Transformiix'"></xsl:if>
<body style="font-family: Verdana, Arial, Helvetica,
sans-serif;font-size:11px;background-color:#EEEEEE">
<xsl:for-each select="testsuite">
<div style="background-color:blue;color:white;padding:4px">
<span style="font-weight:bold">
<xsl:value-of select="@name"/>
<xsl/> Overall Results
</span>
</div>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<span>
<xsl/> tests:
</span>
<xsl:value-of select="@tests"/>
</div>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<span>
<xsl/> assertions:
</span>
<xsl:value-of select="@assertions"/>
</div>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<span>
<xsl/> failures:
</span>
<xsl:value-of select="@failures"/>
</div>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<span>
<xsl/> errors:
</span>
<xsl:value-of select="@errors"/>
</div>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<span>
<xsl/> time (seconds):
</span>
<xsl:value-of select="@time"/>
</div>
</xsl:for-each>
<xsl:for-each select="testsuite/testcase">
<div style="color:white;padding:4px">
<xsl:attribute name="style">
<xsl:choose>
<xsl:when test="failure">background-color:red;
color:white;padding:4px;font-weight:bold</xsl:when>
<xsl:when test="@time=0.0">background-color:gray;
color:white;padding:4px;font-weight:bold</xsl:when>
<xsl:otherwise>background-color:green;
color:white;padding:4px;font-weight:bold
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<span><xsl:value-of select="@name"/></span>
</div>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<span>
<xsl/> assertions:
</span>
<xsl:value-of select="@assertions"/>
</div>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<span>
<xsl/> time (seconds):
</span>
<xsl:value-of select="@time"/>
</div>
<xsl:for-each select="failure">
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<span>
<xsl:value-of select="time"/> failure type:
</span>
<xsl:value-of select="@type"/>
</div>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<span>
<xsl/> failure message:
</span>
<xsl:value-of select="@message"/>
</div>
</xsl:for-each>
</xsl:for-each>
<div style="background-color:black;color:white;padding:4px">
<span style="font-weight:bold">
<xsl/> Console Output
</span>
</div>
<xsl:value-of
select="."
disable-output-escaping="yes"/>
</body>
</html>
def write_report(suite)
File.open("#{@basename}-#{suite.name.gsub(/[^a-zA-Z0-9]+/, '-')}--
#{Time.now.strftime("%m-%d-%Y--%H-%m")}.xml", "w") do |f|
f << suite.to_xml
end
end
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . './PEAR/');
require_once 'Testing/Selenium.php';
require_once 'PHPUnit/Framework/TestCase.php';
class check_links extends PHPUnit_Framework_TestCase {
private $sel;
function setUp() {
$this->sel = new Testing_Selenium("*firefox", "www.my-test-url.com/");
$this->sel->start();
$this->sel->setTimeOut(60000);
}
function tearDown() {
$this->sel->stop();
}
function testLinks() {
//delete screenshot files
foreach (glob("C:\\screenshot_repo\\*.png") as $filename) {
unlink($filename);
}
$this->sel->open("/");
$this->linkval = $this->sel->getAllLinks('id=links-div');
//write all the links found on a separate php file in an array form
$txtfile = fopen('dump.php', 'w+');
fwrite($txtfile, "<?php\n\$links_content = array(\n");
for($i = 0, $size = sizeof($this->linkval); $i < $size; $i++) {
$txt = $this->sel->getText("id=".$this->linkval[$i]);
fwrite($txtfile, "array(href=>".'"'.$this->sel->getAttribute(
'id='.$this->linkval[$i].'@href').'"'.','."text=>".'"'.$txt.'")
,'."\t\n");
}
fwrite($txtfile, ");\n?>");
//read the file and get file length
$txtfile = fopen('dump.php', 'r');
$count = 0;
while(fgets($txtfile)) {
$count++;
}
fclose($txtfile);
include 'dump.php';
for ($links=0;$links<=$count-5;$links++) {
$this->sel->open($links_content[$links]['href']);
$this->sel->waitForPageToLoad(30000);
//take a screenshot of the page
$this->sel->windowFocus();
$this->sel->windowMaximize();
$SSPath = 'C:\\screenshot_repo\\';
$this->sel->captureEntirePageScreenshot($SSPath.str_replace(
" ","_",(strtolower($links_content[$links]['text'])))
.".png","");
}
}
}
?>
<?php
$dbname="{database name}";
$cn=mysql_connect('{host}','{username}','{password}') or
die("I Couldn't connect");
$db=mysql_select_db($dbname,$cn) or die("I Couldn't select your database");
$app_table1="{table name}";
?>