Viewed   170 times

I'd like to use Selenium to automate a few web tasks (not for testing). I think I have Selenium RC Server installed, but have no way of writing "test scripts" since I can't find a client driver in PHP (see:

Is there a way for me to use Selenium with PHP? This seems to suggest I need PHPUnit I just want to automate a few tasks, not get involved with a full suite of testing.



Try Following things

  1. Get Phpunit installed and working
  2. Also have JAVA sdk & jre on your pc.
  3. Now record test cases using selenium IDE.
  4. Export the testcases to php files.
  5. Using these exported functions create an library of test cases.
  6. Create suite which calls the functions/tests from library.
  7. Now to execute Start Selenium Server using java command.
  8. Using phpunit Execute the suite.

for refrence how to write these files click here and also try on git hub

Friday, August 5, 2022

You have two choices. You can save the PDF to a file and attach the file or else output it as a string. I find the string output is preferable:

$pdfString = $pdf->Output('dummy.pdf', 'S');

The file name is ignored since it just returns the encoded string. Now you can include the string in your email. I prefer to use PHPMailer when working with attachments like this. Use the AddStringAttachment method of PHPMailer to accomplish this:

$mailer->AddStringAttachment($pdfString, 'some_filename.pdf');
Saturday, October 22, 2022

There are always the exec-familiy functions to execute/spawn another process.

Thursday, November 17, 2022

I've solved .... I'm behind a proxy in my organization so I've to set Proxy.

I've found this: HtmlUnitDriver does not appear to be loading page.

Look for FunThomas424242 comment and watch this link

So the right code is the follow:

package headlessBrowser;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class TestOne {

public static void main(String[] args) {

    // Declaring and initialising the HtmlUnitWebDriver
    HtmlUnitDriver unitDriver = new HtmlUnitDriver();

    // Necessary set Proxy if you're behind it !!!! 
    unitDriver.setProxy("proxy.YOUR-ORGANIZATION.COM", XXXX);

    // open webpage

    System.out.println("Title of the page is -> " + unitDriver.getTitle());

    // find the search edit box on the google page
    WebElement searchBox = unitDriver.findElement("q"));

    // type in Selenium

    // find the search button
    WebElement button = unitDriver.findElement("btnG"));

    // Click the button;

    System.out.println("Title of the page is -> " + unitDriver.getTitle());


The "core" rows are the following

    // Necessary set Proxy if you're behind it !!!! 
    unitDriver.setProxy("proxy.YOUR-ORGANIZATION.COM", XXXX);

where you've to update with your proxy configuration.

Friday, October 28, 2022

You don't have to change the code to run a Selenium test with Jenkins in headless mode.

You can use a Jenkins plugin of a headless X server to run your tests on an installed browser. You will even get screenshots.

Monday, November 21, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :