phptestingselenium-webdriverphp-parse-error

Parse error in php web driver


I have no idea about PHP programming before. Now I am working on selenium using Facebook php web driver. I have just started with very basic test code that is to open pages and click links and so on. But I got stuck just after few lines of code and it shows a parse error. I couldn't find what the parse error is? It would really grateful if someone can help me out. Here is my few lines of code..

<?php

use Facebook\WebDriver\Remote\DesiredCapabilities; 
use Facebook\WebDriver\Remote\RemoteWebDriver;

require_once 'vendor/Autoload.php';

$host = 'http://localhost:4444/wd/hub'; // this is the default
$capabilities = DesiredCapabilities::firefox();
$driver = RemoteWebDriver::create($host, $capabilities, 5000);

$driver->get('http://qa.practera.com');

$link =$driver>findElement(WebDriverBy::xpath('//a[@href='login']'));
$link->click();
?>

Result:

Parse error: parse error in /Users/srujanareddyenugala/Desktop/php-webdriver/1.php on line 14

I am an intern and trying to learn by looking at some examples because my mentor just want me to learn by myself. I want to start from basics but they are not giving me enough time and wants me to do just by going through examples and understand. It will be very helpful if someone can help me by giving advices how to learn quickly and also could suggests me with some websites or books or online courses.

Thanks in advance!!


Solution

  • This line

    $link =$driver>findElement(WebDriverBy::xpath('//a[@href='login']'));
    

    To

    $link =$driver->findElement(WebDriverBy::xpath('//a[@href='login']'));
    

    you are missing a - sign