How to test a Web site by driving Konqueror thru its equivalent of Automation?

Koos Vriezen koos.vriezen at xs4all.nl
Sun Jun 20 13:20:30 BST 2004


On Sat, Jun 19, 2004 at 08:00:32PM -0700, Phlip wrote:
> KDE developers:
> 
> This Ruby code drives IE thru ActiveX, to surf to a
> Web page on my local server, write on its form, and
> click its Save button:
> 
>    ie = WIN32OLE.new('InternetExplorer.Application')
>    ie.navigate(
>      'http://127.0.0.1:8080/WikiTranscludeText')
> 
>         while ie.busy
>             sleep(0)
>         end
> 
>         until ie.readyState == READYSTATE_COMPLETE
>             sleep(0)
>         end
> 
> # ie.Visible = true
> 
>    formNode = ie.document.forms("files/sample.txt")
>         assert_not_nil(formNode)
>         inputNode = formNode.namedItem("contents")
>         assert_not_nil(inputNode)
> 
>    inputNode.setAttribute('value', 'What\'s up Doc?')
> 
>         saveButton = formNode.namedItem("Save")
>         assert_not_nil(saveButton)
>         saveButton.click()
> 
> I enjoy Konqueror as a user, but not as a programmer,
> so to translate that into the KDE-land equivalent, I'm
> in a situation where I don't know what I don't know.
> 
> If the KDE equivalent of ActiveX is DCOP, can it be
> scripted that easily? How can one get into the DOM
> inside a page?

Note, I'm no expert on this. Just some thoughts..

I think this is more a question for the kde-bindings mailing list. And forget
about DCOP accessing the DOM though, DCOP is flat.

I've played a bit with kjsembed lately (note: there are other bindings too)
and there is a poor man's way to access khtml DOM tree. You have to write JS
and parse evaluate ouput yourself.
Eg in:

#!/usr/bin/env kjscmd

function Slots() {
    this.pageLoaded = function() {
         println ("loaded");
         part.executeScript('document.forms[0].elements("unickname").value="What\'s up Doc?"');
    }
}
var mw = new KMainWindow();
var box = new QVBox( mw );
var slots_obj = new Slots();
mw.setCentralWidget(box);
var part = Factory.createROPart("text/html", box, "html widget");
part.openURL( "http://slashdot.org" );
mw.connect(part, "completed()", slots_obj, "pageLoaded");
print(part.signals());
mw.show();
application.exec();

you could check return value from executeScript() call.
However you probably want a real binding to the DOM ...

Koos




More information about the kfm-devel mailing list