I was writing a code for Google search help functionality and want to print the related topic which will appear .
that is when we type any word in the Google search area some related topics appear under the search area , i was trying to automate that functionality using php-webdriver-bindings By Lukasz Kolczynski and trying to print those topics as out put
using Selenium Ide i can store the Xpath count in a variable and using loop i can easily print those but in selenium 2 using php-webdriver-bindings code i am not able to print .
the code i have written so far is given below
<?php
require_once 'www/library/phpwebdriver/WebDriver.php';
class PHPWebDriverTest extends PHPUnit_Framework_TestCase {
protected $webdriver;
protected function setUp() {
$this->webdriver = new WebDriver("localhost", 4444);
$this->webdriver->connect("firefox");
}
protected function tearDown() {
// $this->webdriver->close();
}
public function testgooglesearch() {
$this->webdriver->get("http://google.com");
$element=$this->webdriver->findElementBy(LocatorStrategy::name, "q");
$element->sendKeys(array("selenium google code" ));
$element1=$this->webdriver->findElementBy(LocatorStrategy::xpath,"//*[@id='gsr']/table/tbody/tr/td[2]/table/tbody/tr[*]/td']");
echo $element1;
}
}
?>
when i am trying to print element1 error is showing.
can any one please help me how i can proceed.
--You received this message because you are subscribed to the Google Groups "Selenium Users" group.To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/4hpQVznZ4YIJ.
<?php
require_once "/phpwebdriver/WebDriver.php";
class WebdriverTest extends PHPUnit_Framework_TestCase
{
protected $webdriver;
protected function setUp()
{
$this->webdriver=new WebDriver("localhost", 4444);
$this->webdriver->connect("firefox");
}
protected function tearDown() {
$this->webdriver->close();
}
public function testSearch()
{
$this->webdriver->get("http://google.com");
$element=$this->webdriver->findElementBy(LocatorStrategy::name,"q");
$element->sendKeys(array("selenium" ) );
sleep(2);
$result=$this->webdriver->findElementsBy(LocatorStrategy::xpath,"//td[@class='gssb_a gbqfsf']");
$countresult=count($result);
echo "Records Count = ". $countresult ."\n";
$x=1;
$y=0;
echo "\n";
while($y<$countresult)
{
$output=$result[$y]->getText();
echo $output."\n";
$x++;
$y++;
}
$r=$this->webdriver->findElementBy(LocatorStrategy::xpath,"//div[@class='gbqlca']");
$r->click();
}
}
?>
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/F1dqV91OYAoJ.