Code Monkey home page Code Monkey logo

cfselenium's Introduction

Build Status

CFSelenium - A Native CFML (ColdFusion) Client Library for the Selenium WebDriver

What is CFSelenium?

CFSelenium is a ColdFusion Component (CFC) which provides a native client library for the Selenium WebDriver. This allows you to write tests, using CFML, which will drive a browser and verify results.

This version has dropped support for Selenium-RC and Selenium-IDE. Also the tests have been rewritten for TestBox by Ortus Solutions.

Requirements

  1. Lucee 4.5+ or Adobe ColdFusion 11+
  2. TestBox if you want to run the test suite

Implementation

Ensure that the standalone Selenium Server jar file is in your Java load path. You can add this to your Application.cfc to ensure the file is loaded.

this.javaSettings = { loadPaths = [ '/path/to/cfselenium/lib/selenium-server-standalone-3.4.0.jar' ] };

To create an instance of Selenium WebDriver:

selenium = new cfselenium.SeleniumWebDriver( driverType="firefox", webDriver="path/to/webdrivers/webDriverFilename" );

where webDriverFilename is the binary for the platform you are running. See the example in tests/specs/firefoxSpec.cfc

Currently the Firefox WebDrivers for both Macintosh and Windows are provided. Other browsers and operating systems will be added as test coverage increases.

Using WebDriver

Example: Get a page title.

selenium = new cfselenium.SeleniumWebDriver( driverType="firefox", webDriver="path/to/webdrivers/webDriverFilename" );
driver = selenium.getDriver();
driver.get( "https://www.google.com" );
writedump( var="#driver.getTitle()#" ); // evaluates to "Google"
driver.quit();

Testing

Running the Tests

cd /path/to/my/webroot/ # or wherever you want to put stuff
git clone https://github.com/teamcfadvance/CFSelenium.git cfselenium
cd cfselenium
git checkout master
git clone https://github.com/Ortus-Solutions/TestBox.git testbox
cd testbox
git checkout master
Multi-CFML-Engine Testing using CommandBox

One super-easy way to do tests in different CFML engines is this is to install CommandBox by Ortus Solutions , run the executable, then, within CommandBox:

cd /path/to/my/webroot/ # or wherever you'd put it
# testing in Lucee 4.5, for instance
server start [email protected] # when done testing, run `stop`
# testing in ACF 11, for instance
server start cfengine=adobe@11 # when done testing, run `stop`

That will open a browser window with a random port (e.g., 62261), after which, browse to the following to run the tests and see the results:

Support

Please use the main repo's issue tracker to report bugs and request enhancements.

Credits

The script-based version of CFSelenium was created by Bob Silverberg and the tag-based version was created by by Brian Swartzfager. Marc Esher provided the logic which starts and stops the Selenium-RC server automatically. @Lampei and Jamie Jackson added WebDriver support.

Richard Herbert refactored the WebDriver approach and removed support for Selenium-RC and Selenium-IDE. The tests were rewritten using TestBox/CommandBox and MXUnit has been removed.

cfselenium's People

Contributors

adrianblynch avatar bcswartz avatar bobsilverberg avatar cfoutlaw avatar dannycork avatar ddspringle avatar dominicwatson avatar gregmoser avatar jamiejackson avatar lampei avatar marcesher avatar richardherbert avatar zoconet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cfselenium's Issues

Forgebox Module?

Thanks so much for putting this together! Have you considered making this a Forgebox module that could be installed on Coldbox apps or via Commandbox? This would be a great addition to the other modules on Forgebox.

java.lang.NumberFormatException: For input string: "v0"

I tried to setup WebDriver tests and keep getting the error java.lang.NumberFormatException: For input string: "v0". I wondered someone can give me some guidance please?

I'm using TestBox and it extending mxunit, Lucee 4.5.2. I assume CFSelenium WebDriver compatible with Lucee 4.5.2 since it didn't mention on read.me.

Here's the error trace:
system.basespec_cfc$cf.udfCall3(F:\Workspace\testbox\system\BaseSpec.cfc:532)
system.testbox_cfc$cf.udfCall1(F:\Workspace\testbox\system\TestBox.cfc:144).
system.testbox_cfc$cf.udfCall1(F:\Workspace\testbox\system\TestBox.cfc:216)
system.testbox_cfc$cf.udfCall2(F:\Workspace\testbox\system\TestBox.cfc:414)
system.runners.unitrunner_cfc$cf.udfCall(F:\Workspace\testbox\system\runners\UnitRunner.cfc:84)
system.runners.unitrunner_cfc$cf.udfCall(F:\Workspace\testbox\system\runners\UnitRunner.cfc:213)
system.basespec_cfc$cf.udfCall3(F:\Workspace\testbox\system\BaseSpec.cfc:841)
test.v2.seleniumtest_cfc$cf.udfCall(F:\Workspace\CFSelenium\test\v2\seleniumTest.cfc:12)
selenium_cfc$cf.udfCall(F:\Workspace\CFSelenium\selenium.cfc:9)
selenium_cfc$cf.udfCall(F:\Workspace\CFSelenium\selenium.cfc:27)
cfselenium.drivers.firefoxdriver_cfc$cf.udfCall(F:\Workspace\CFSelenium\drivers\FireFoxDriver.cfc:9)
cfselenium.drivers.webdriver_cfc$cf.udfCall4(F:\Workspace\CFSelenium\drivers\WebDriver.cfc:300)

299: javaFactory.createObject(
300: "io.github.bonigarcia.wdm.#driverName#DriverManager"
301: ).getInstance().setup();

Pathing issues

I've installed the jar here: E:\ColdFusion2018\Instance\lib\CFSelenium-master\lib\selenium-server-standalone-3.4.0.jar

In my application.cfc I have this line:
this.javaSettings = { loadPaths = [ 'E:/ColdFusion2018/Instance/lib/CFSelenium-master/lib/selenium-server-standalone-3.4.0.jar' ], loadColdFusionClassPath = true, reloadOnChange = true };

The application is 2 directories down from the instance root: /Util/Selenium/test.cfc

Restart server and run the code:
webdriver = "E:/ColdFusion2018/Instance/lib/CFSelenium-master/webdrivers/geckodriver-v0.16.1-win64.exe";
selenium = new cfselenium.SeleniumWebDriver( driverType="firefox", webdriver=webdriver );

ColdFusion says Could not find the ColdFusion component or interface cfselenium.SeleniumWebDriver.

What am I missing?

CFSelenium - handling file uploads

When converting the html (xml format) created by the Firefox IDE to ColdFusion cfc's, for file uploads it creates the same format as for typing in text,
selenium.type("id=inputid","localfilepath");

This does not work for uploading files when converted to Java for CFSelenium. An example for "Selenium4j" which uses JUnit testing via Eclipes is to replaces the
session().type("id=inputid","localfilePath")
with a wrapped FirefoxDriver and
firefoxDriver.findElement(By.id("id=inputid")).sendKeys("localfilePaths");

I am seeking a successful format for testing forms wtih document uploads using CFSelenium.

Thank you,
Steve

Problem with example on README

After upgrading to the latest version, I am having trouble getting tests to run by following the example posted on the README file (I am using Testbox):

component extends="testbox.system.BaseSpec"{
    this.javaSettings = { loadPaths = [ '/cfselenium/lib/selenium-server-standalone-3.4.0.jar' ] };

    // executes before all suites
    function beforeAll(){
		selenium = new cfselenium.SeleniumWebDriver( driverType="firefox");
		driver = selenium.getDriver();
		driver.get( "https://www.google.com" );
		writedump( var="#driver.getTitle()#" ); // evaluates to "Google"
    }

    // executes after all suites
    function afterAll(){
		driver.quit();
    }
}

This generates the following error:

`The parameter webdriver to function init is required but was not passed in.`

If I do specify the webdriver, however, I get another error:

component extends="testbox.system.BaseSpec"{
    this.javaSettings = { loadPaths = [ '/cfselenium/lib/selenium-server-standalone-3.4.0.jar' ] };

    // executes before all suites
    function beforeAll(){
		selenium = new cfselenium.SeleniumWebDriver( driverType="firefox", webdriver="FirefoxDriver");
		driver = selenium.getDriver();
		driver.get( "https://www.google.com" );
		writedump( var="#driver.getTitle()#" ); // evaluates to "Google"
    }

    // executes after all suites
    function afterAll(){
		driver.quit();
    }

Error:

cannot load class through its string name, because no definition for the class with the specified name [org.openqa.selenium.firefox.FirefoxDriver] could be found caused by (java.lang.ClassNotFoundException:org.openqa.selenium.firefox.FirefoxDriver;java.lang.ClassNotFoundException:org.openqa.selenium.firefox.FirefoxDriver not found by lucee.core [46];)

A similar error occurs if I try "WebDriver" instead of "FireFoxDriver".

I have also used relative and full paths in the line below with the same results:

this.javaSettings = { loadPaths = [ '/cfselenium/lib/selenium-server-standalone-3.4.0.jar' ] };

Any insight on what I am missing?

Installing the formatter for Selenium IDE

Can anyone help me with installing the formatter for Selenium IDE please? I tried to install it in FF version 49.0.1 but I get a message that says it can't be installed because it has not been verified. I already have the flag in Firefox xpinstall.signatures.required set to false but it does not seem to make any difference.

Any Ideas on how to do that?

New Version Defaults to Version 2 (WebDriver)

Now that I'm actually integrating @Lampei's/my pull request into a project, I notice a change that enables WebDriver ("version 2" mode) by default.

That means that existing tests will often fail, because RC and WebDriver don't have all of the same functionality.

Here's an example from ValidateThis (a consumer of CFSelenium):

    public void function beforeTests() {
        baseurl = "http://#cgi.server_name#:#cgi.server_port#";
        browserUrl = "#baseUrl#/validatethis/samples/FacadeDemo/";
        super.beforeTests();
        selenium.setTimeout(30000);
        crlf = chr(10);
    }

The super call would need to be changed to point back to the old version, in order for tests to work:

super.beforeTests(version=1, browserUrl=browserUrl);

It might have been better to preserve seamless backward compatibility by defaulting to v1 (RC), then folks could upgrade, when they see fit, to v2 (Webdriver) by changing their beforeTests() accordingly.

@Lampei, @ddspringle, et al,, thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.