Running selenium Java scripts in Linux Non-GUI servers with PhantomJs

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Running selenium Java scripts in Linux Non-GUI servers with PhantomJs

Suresh babu-3
HI Team,

As of now iam using windows machine and developed some scripts and executed -- everything works fine in this scenario

but when i try to execute same scripts in Linux machine (Linux machine-- with out GUI only command line we have) scripts are not executing.

Procedure followed to execute scripts in linux machine:

1. Maintained all jars(TestNG and Selenium Stand alone) in lib folder 
2. I have used Phantom JS which is used for Headless browser for testing

Sample java code but not the exact app elements:

               File file = new File("path of pahntomjs driver");
System.setProperty("phantomjs.binary.path", file.getAbsolutePath());
WebDriver driver = new PhantomJSDriver();
driver.manage().window().setSize(new Dimension(1400,1000));
driver.get("https://www.google.com/");
driver.manage().deleteAllCookies();
driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.findElement(By.xpath("//*[@id="lst-ib"]")).sendKeys("Test");
driver.findElement(By.name("btnK")).click();
Thread.sleep(3000);
driver.close();

Note: Executed above scripts in windows it worked fine but where as in Linux command line it is not executing and getting below error.

Error message: errorMessage":"Unable to find element with xpath '//input[@id='pt1:_pt_it1::content']'"



Executed below lines of statements in putty (command linux server):

javac -classpath "/tmp/SeleniumUsecases/lib/*" -d ./bin ./src/Testcases/*.java
java -classpath /tmp/SeleniumUsecases/lib/*:/tmp/SeleniumUsecases/bin org.testng.TestNG /tmp/SeleniumUsecases/testng.xml 


Please provide any inputs on this

Thanks in Advance.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/91945f3e-7222-4b13-a8e0-4521bebd0d04%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Running selenium Java scripts in Linux Non-GUI servers with PhantomJs

Shawn McCarthy-2
Why are you using phantomjs ? I believe it is deprecated, since firefox and chrome both have --headless flags.


On Wednesday, July 11, 2018 at 9:09:09 PM UTC-7, Suresh babu wrote:
HI Team,

As of now iam using windows machine and developed some scripts and executed -- everything works fine in this scenario

but when i try to execute same scripts in Linux machine (Linux machine-- with out GUI only command line we have) scripts are not executing.

Procedure followed to execute scripts in linux machine:

1. Maintained all jars(TestNG and Selenium Stand alone) in lib folder 
2. I have used Phantom JS which is used for Headless browser for testing

Sample java code but not the exact app elements:

               File file = new File("path of pahntomjs driver");
System.setProperty("phantomjs.binary.path", file.getAbsolutePath());
WebDriver driver = new PhantomJSDriver();
driver.manage().window().setSize(new Dimension(1400,1000));
driver.get("<a href="https://www.google.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/&#39;;return true;" onclick="this.href=&#39;https://www.google.com/&#39;;return true;">https://www.google.com/");
driver.manage().deleteAllCookies();
driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.findElement(By.xpath("//*[@id="lst-ib"]")).sendKeys("Test");
driver.findElement(By.name("btnK")).click();
Thread.sleep(3000);
driver.close();

Note: Executed above scripts in windows it worked fine but where as in Linux command line it is not executing and getting below error.

Error message: errorMessage":"Unable to find element with xpath '//input[@id='pt1:_pt_it1::content']'"



Executed below lines of statements in putty (command linux server):

javac -classpath "/tmp/SeleniumUsecases/lib/*" -d ./bin ./src/Testcases/*.java
java -classpath /tmp/SeleniumUsecases/lib/*:/tmp/SeleniumUsecases/bin org.testng.TestNG /tmp/SeleniumUsecases/testng.xml 


Please provide any inputs on this

Thanks in Advance.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/70757ff2-3b91-4900-b953-31e21923baf6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Running selenium Java scripts in Linux Non-GUI servers with PhantomJs

Suresh babu-3
I have tried with chrome but when I compile and run the program getting this error ‘GLIBC_2.4 not found’

Tried to set GLIBC issue but after that it’s not getting compiled only and system is getting hanged

my current system configuration is “CENTOS 6” command terminal (might be it is not supporting chrome)

Hence using phantomJs here that driver itself not recognising

Please let me know if you have any inputs to overcome this issue

Regards,
Suresh.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/36674300-8608-4c81-893c-74db9e79ac7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Running selenium Java scripts in Linux Non-GUI servers with PhantomJs

Serguei Kouzmine
In reply to this post by Suresh babu-3
Hello Babu
 
The code snippet provided in the question appears very basic. Try adding taking screnshots and a few assertions against page url, page contents, search  for some other elements to narrow down the problem to an invalid locator or inability to run the app   or something else,
   BTW You can sure try the phantomjs on windows to narrrow it down even further. 

Sorry to hear about the problem with glibc.  You sure can try it with headless Firefox, it may not need that particular version

Thanks

Serguei Kouzmine

As of now iam using windows machine and developed some scripts and executed -- everything works fine in this scenario

but when i try to execute same scripts in Linux machine (Linux machine-- with out GUI only command line we have) scripts are not executing.

Procedure followed to execute scripts in linux machine:

1. Maintained all jars(TestNG and Selenium Stand alone) in lib folder 
2. I have used Phantom JS which is used for Headless browser for testing

Sample java code but not the exact app elements:

               File file = new File("path of pahntomjs driver");
System.setProperty("phantomjs.binary.path", file.getAbsolutePath());
WebDriver driver = new PhantomJSDriver();
driver.manage().window().setSize(new Dimension(1400,1000));
driver.get("<a href="https://www.google.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/&#39;;return true;" onclick="this.href=&#39;https://www.google.com/&#39;;return true;">https://www.google.com/");
driver.manage().deleteAllCookies();
driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.findElement(By.xpath("//*[@id="lst-ib"]")).sendKeys("Test");
driver.findElement(By.name("btnK")).click();
Thread.sleep(3000);
driver.close();

Note: Executed above scripts in windows it worked fine but where as in Linux command line it is not executing and getting below error.

Error message: errorMessage":"Unable to find element with xpath '//input[@id='pt1:_pt_it1::content']'"



Executed below lines of statements in putty (command linux server):

javac -classpath "/tmp/SeleniumUsecases/lib/*" -d ./bin ./src/Testcases/*.java
java -classpath /tmp/SeleniumUsecases/lib/*:/tmp/SeleniumUsecases/bin org.testng.TestNG /tmp/SeleniumUsecases/testng.xml 


Please provide any inputs on this

Thanks in Advance.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/1a95a103-3f3e-42d9-9650-c5e244c12411%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.