-2

I want to install selenium on centos 6.5 and than use it through APIs in PHP script.

Selenium Test scripts will be recorded on another system and those Selenium Test scripts will be given as input to PHP. How to do?

Gaur
  • 1
  • 7
  • What have you tried so far ? And any particular reasons for this complicated setup ? What would it achieve ? – Sam May 04 '16 at 14:08
  • I have tried Selenium IDE add in firefox and recorded certain test cases, its doing well. – Gaur May 05 '16 at 05:49
  • But I want to use these recorded test cases to be given as an input to selenium server installed at centos and I want to run those test cases from there. – Gaur May 05 '16 at 05:50
  • Ok, so as I understand on machine x you will record / create the test cases someway (either through IDE or APIs), and then run them on centos machine y. So essentially you need to setup a selenium grid on machine y, and either use a headless browser or install Gnome desktop and use a real browser (Firefox for example). – Sam May 05 '16 at 10:09
  • Yes, Now you got it right. But I don't want to open the browser(not manually, nor by running script) to run the recorded Selenium test case. I want to execute the Selenium test case in back-end and the result of script should be displayed only. – Gaur May 05 '16 at 13:29
  • Please give a detailed solution. Thanks – Gaur May 05 '16 at 13:30
  • I want to execute slenium test script on centos from commandline-without browser – Gaur May 09 '16 at 07:21
  • I have installed Selenium web driver on centos – Gaur May 09 '16 at 07:26
  • And now I want to execute recorded selenium test script by giving that script as an input to command line execution – Gaur May 09 '16 at 07:28
  • I won't be able to help unless you share what you have tried so far ? Is the grid setup ? Did you run the recorded script using the grid on that CentOS server ? – Sam May 09 '16 at 11:32
  • Whateve I tried, Thats what I told abve that: " I have installed java and selelium-standalone server " on centos and I have many recorded slenium test scripts. – Gaur May 09 '16 at 12:10
  • Now, only thing I want is that: '" How can I provide these recorded scripts to selenium server on centos through command lind and those scripts should execute, and running of these scripts is not supposed to populate browser, as I want to use CentOs in text mode only. No GUI. – Gaur May 09 '16 at 12:13
  • Have a look at this: http://stackoverflow.com/questions/10359586/running-selenium-ide-tests-via-selenium-grid – Sam May 09 '16 at 14:08
  • Although I don't understand where PHP comes in this whole picture. – Sam May 09 '16 at 14:09
  • Ohh, It means that you have not got a clear scenario where I want to use Selenium automation. PLz go through below description: – Gaur May 10 '16 at 04:46
  • My selenium server is on centos machine, my recorded selenium test scripts are on another machines(Windows / LINUX). Selenium server will be started remotely through web interface. And now I want to supply the recorded selenium test scripts to selenium server which is on centos through web interface, here comes PHP in the picture to supply the recorded test script to selenium server through web interface. I have all other stuff, I just need help that how can I supply the test script to selenium server on port no: 4444, over web using php. – Gaur May 10 '16 at 04:54
  • And how to make selenium server to accept those test scripts and execute them and get the result back. Plz help... – Gaur May 10 '16 at 04:57
  • Hey Sam, Plz look into it – Gaur May 12 '16 at 05:51
  • The current status is as following, where I am right now, after lot of RnD on this topic: – Gaur May 12 '16 at 05:52
  • "phpunit --verbose phproTest.php" This command gives result as:- Runtime: PHP 5.4.45 S Time: 1 minute, Memory: 12.00Mb There was 1 skipped test: 1) phproTest::testTitle The Selenium Server is not active on host localhost at port 4444. OK, but incomplete, skipped, or risky tests! Tests: 1, Assertions: 0, Skipped: 1. Even though my selenium server is running on port: 4444. It tells that The selenium server is not active.... – Gaur May 12 '16 at 05:53
  • And On server side:- export DISPLAY=":1" && java -jar selenium-server-standalone-2.44.0.jar here comes started. On request of phpunit:11:30:11.039 INFO - Executing: [new session: Capabilities [{browserName=firefox}]]) 11:30:11.052 INFO - Creating a new session for Capabilities [{browserName=firefox}] org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. – Gaur May 12 '16 at 06:07
  • "Unable to connect to host 127.0.0.1 on port 7055" is a symptom of incompatibility between FF version and Selenium webdriver. Try using selenium 2.25 instead of 2.44. – Sam May 12 '16 at 09:45
  • "Even though my selenium server is running on port: 4444. It tells that The selenium server is not active..." - its seems to be looking on localhost:4444. Are you sure you are passing it the remote server's IP with port 4444 ? – Sam May 12 '16 at 09:45
  • yes, Plz look at seup() function: – Gaur May 12 '16 at 09:51
  • protected function setUp() { $this->setHost('localhost'); $this->setPort(4444); $this->setBrowser('firefox'); $this->setBrowserUrl('http://www.phpro.org/'); } – Gaur May 12 '16 at 09:51
  • "$this->setHost('localhost')". You are setting it to localhost, while your selenium server is running on a remote CentOS machine. You should pass it the IP of the machine that is running your selenium grid server – Sam May 12 '16 at 10:24
  • No no, its just for testing purpose, I'm doing on same machine – Gaur May 12 '16 at 12:01
  • I am confused. So what happens when you navigate to localhost:4444/wd/hub in a browser on your local machine ? – Sam May 12 '16 at 13:33
  • I'm not using browser, I am running this script on centos textmode. And I get following output when I run it like this: – Gaur May 13 '16 at 06:00
  • phpunit --verbose /root/prakash/phproTest.php PHPUnit 5.3.4 by Sebastian Bergmann and contributors. Runtime: PHP 5.6.21 S 1 / 1 (100%) Time: 1 minute, Memory: 10.75Mb There was 1 skipped test: 1) phproTest::testTitle The Selenium Server is not active on host localhost at port 4444. – Gaur May 13 '16 at 06:03
  • Server status in another tab is: 11:34:04.879 INFO - Started HttpContext[/selenium-server,/selenium-server] 11:34:04.927 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@6ad5c04e 11:34:04.928 INFO - Started HttpContext[/wd,/wd] 11:34:04.928 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver] 11:34:04.928 INFO - Started HttpContext[/,/] 11:34:04.933 INFO - Started SocketListener on 0.0.0.0:4444 11:34:04.933 INFO - Started org.openqa.jetty.jetty.Server@b1bc7ed – Gaur May 13 '16 at 06:05
  • And on server side I'm getting this: Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms, After completion of phpunit script execution – Gaur May 14 '16 at 11:13

1 Answers1

0

Thanks a lot Sam and othre for taking interest in this question. After Lot of R&D finally I got it running by downgrading firefox version.

You can get it working with: selenium-server-standalone-2.53.0.jar AND Mozilla Firefox 38.6.1.

On Centos6.5 Text Mode

Gaur
  • 1
  • 7