WebTesting library

Kingsley via Digitalmars-d digitalmars-d at puremagic.com
Fri Jan 22 17:24:49 PST 2016


On Friday, 22 January 2016 at 21:43:35 UTC, Keywan Ghadami wrote:
> On Friday, 22 January 2016 at 20:16:12 UTC, Kingsley wrote:
>> Hi,
>>
>> I don't know if this is of interest to anyone but I've created 
>> a webtesting library that is basically a phantomjs driver. It 
>> looks similar to Webdriver/Selenium but its in D.
>>
>> I have been using it to functionally test my web apps. If 
>> anyone is remotely interested I will publish it on dub.
>>
>> --Kingsley
>
> I guess you are talking about https://github.com/kingsleyh/erik 
> ?
> Can you tell more about it. You write tests in D and "erik" 
> runs them with phantom.js?
> Is something special when using it together with vibe.d?
> Is there anything planed to put on top on it like behat?
> Is it compatible with selenium. E.g. can you run tests in the 
> cloud or differnt browsers.
>
> Sorry for asking maybe stupid questions.

Hey - yeah thats it.

I have been using d-unit to write the tests and using erik as the 
tool to operate and drive the browser - in this case the 
phantomjs headless javascript browser.

an example might be:
     @Test
     public void doit(){
       Session session = Session.start(); // start new phantom on 
random port
       session.visitUrl("http://www.google.com"); // visit url
       By search = By.cssSelector("input[name='q']");
       session.waitFor(search, Condition.isClickable()); // wait 
for search box to appear
       WebElement searchBox = session.findElement(search); // 
select search box
       searchBox.sendKeys("d language kingsley");                  
    // type into search box
       writeln(searchBox.getAttribute("value"));           // get 
search box value
     }

There is currently nothing special for vibe.d - however I'm 
planning on doing some better integration there.
I may write a cucumber/behat/jbehave thing that it could hook into
It's currently not directly compatible with selenium - the hooks 
exist but I haven't pushed them forward - but it would not be 
hard to support selenium for driving different browsers.

I'm not 100% in which direction it will go at the moment as only 
the basics are implemented.


More information about the Digitalmars-d mailing list