Parse error in php web driver - php

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!!

This line
$link =$driver>findElement(WebDriverBy::xpath('//a[#href='login']'));
To
$link =$driver->findElement(WebDriverBy::xpath('//a[#href='login']'));
you are missing a - sign

Related

Having trouble connecting to neo4j with neo4jClient Everyman

I am creating a project using php in eclipse and neo4j. I am having problems connecting though. This is the code I have written to connect to the database.
<?php
include("neo4jphp.phar");
use Everyman\Neo4j\Client;
$neo4jClient = new \Everyman\Neo4j\Client('https://127.0.0.1:7474',7474);
$neo4jClient->getTransport()
->setAuth('username','password')
->getTransport()->useHttps();
and here is the link to show the error I am having.
Link: https://selene.hud.ac.uk/irr/connect.php
According to my research this should be correct. I am also using this video to help me with the connection: https://vimeo.com/125334699
Some guidance in the right direction using my code will be appreciated.

Cannot find out what's wrong with my require_once call to YouTube API

I'm trying to use the google API as long as some other API but it seems that there is no way to make it work.
I get the error message
Fatal error: Class 'Google_Service' not found in /home/msc/www/wp-content/plugins/wp-posts/lib/Google/Service/YouTube.php on line 32
The whole site is under wordpress 4,1,1
thanks in advance.
The answer was simple enough
I added
require_once 'Google/autoload.php';
based on this topic :
Link here
You need to set an include path that points to where the /Google folder is
set_include_path('C:/path/to');

Class AlchemyAPI not found error

I need help guys, are you familiar with the alchemy api? It's an SEO tool that runs on different platforms and what it does is extract contents from web pages it uses the principle of content scraping.
I downloaded the php SDK for alchemy api and I got an error I cannot load the page and if anyone here in this forum that is familiar with alchemy api or good with php i really need your help guys. the error says:
Fatal error: Class 'AlchemyAPI' not found in line 44
Here is my code:
function CheckNoParams() {
$alchemyObj = new AlchemyAPI(); // line 44
$alchemyObj->loadAPIKey("api_key.txt");
$htmlFile = file_get_contents("../example/data/example.html");
$htmlFile2 = file_get_contents("../example/data/example2.html");
}
Looks like you haven't use include. Try this:
function CheckNoParams() {
include "./module/AlchemyAPI.php";
$alchemyObj = new AlchemyAPI(); // Now line 45 :-P
$alchemyObj->loadAPIKey("api_key.txt");
$htmlFile = file_get_contents("../example/data/example.html");
$htmlFile2 = file_get_contents("../example/data/example2.html");
}
(Assuming you have preserved the original file structure when you downloaded the Alchemy's PHP SDK)

Errors when implementing WURFL with Zend

I've looked around and cant seem to find someone with the same issue as me, hoping i've not missed a clanger here.
I'm wanting to get device browser information for each user, i'm currently planning on doing this within the bootstrapper, following something i saw in PHP conference.
To that end i came across:
http://framework.zend.com/manual/en/zend.http.user-agent.html
Which explains how to install and use wurfl. I've followed the instructions and am coming up with the following exception:
Uncaught exception 'Zend_Http_UserAgent_Features_Exception' with message '"wurflapi" configuration is not defined'
My limited understanding of Zend leads me to think the issue is within configs/application.ini
I have the following:
resources.useragent.wurflapi.wurfl_api_version = "1.1"
resources.useragent.wurflapi.wurfl_lib_dir = APPLICATION_PATH "/../library/wurfl-php-1.1/"
resources.useragent.wurflapi.wurfl_config_file = APPLICATION_PATH "/configs/wurfl-config.php"
Where my wurfl-config.php looks like:
echo "Loaded";
die;
$resourcesDir = dirname(__FILE__) . '/../../data/wurlf/';
$wurfl['main-file'] = $resourcesDir . 'wurfl-latest.zip';
$wurfl['patches'] = array($resourcesDir . 'web_browsers_patch.xml');
$persistence['provider'] = 'file';
$persistence['dir'] = CACHE_ROOT . "/wurfl/";
$cache['provider'] = null;
$configuration['wurfl'] = $wurfl;
$configuration['persistence'] = $persistence;
$configuration['cache'] = $cache;
I'm expecting the script to die after priting loaded, but i'm not getting this, meaning the config isnt loading correctly.
Where might be the problem? What more information do you require? Has anyone else come across this dilemma before?
Thanks in advance
Seems that you're unable to do what i want.
In that this doesnt seem to want to work within a bootstrap. Instead you should do this as a plugin.
This video tutorial helps explain the documentation a little better:
http://mcloide.wordpress.com/2010/12/08/mobile-development-with-zend-framework-and-wurfl/
Now that i have setup the plugin i dont get the exception and my config loads perfectly. Humpf!!

Crystal Report in php

How I can create a crystal report in php kindly guide me so that I can make it possible. I have tried a lot of code and tutorials but un-usefull for me.
I have tried
$COM_Object = "CrystalReports12.ObjectFactory.1";
$my_report = "C:\\Report2.rpt";
$ObjectFactory= New COM($COM_Object);
$creport = $ObjectFactory->OpenReport("c:\\report2.rpt", 1);
Here is the error is
Fatal error: Call to undefined method com::OpenReport()
any one can help me i m very thankful for that preson
This may help you.
Use XML + XSL:FO with Apache FOP via PHP-JavaBridge.
Here is how: http://wiki.apache.org/xmlgraphics-fop/HowTo/PHPJavaBridge
PostScript would be nice!

Categories