peerigon / phridge

A bridge between node and PhantomJS
The Unlicense
519 stars 50 forks source link

Update Readme.md #4

Closed PrototypeAlex closed 10 years ago

PrototypeAlex commented 10 years ago

Super small change, but I found the api docs showing what the webpage instance has access to handy for reference, so I've added the link to the phantom.js webpage module and bound url to this in the example.

coveralls commented 10 years ago

Coverage Status

Coverage remained the same when pulling a75f90e35cacf0129647b5ffed8abed23e362bf5 on PrototypeAlex:master into 218606a45995fb6a0ba441aff31264591a6078cf on peerigon:master.

jhnns commented 10 years ago

That's better, thx! :+1:

Concerning this.url: Are you sure that this is bound to the page instance?

PrototypeAlex commented 10 years ago

Yup, but how I found that out is pretty gross, not my proudest moment.... :grinning:

page.open "http://google.com/", (status) ->
  console.log Object.getOwnPropertyNames(this)

Outputs:

objectName,title,frameTitle,content,frameContent,url,frameUrl,loading,loadingProgress,canGoBack,canGoForward,plainText,framePlainText,libraryPath,offlineStoragePath,offlineStorageQuota,viewportSize,paperSize,clipRect,scrollPosition,navigationLocked,customHeaders,zoomFactor,cookies,windowName,pages,pagesWindowName,ownsPages,framesName,frameName,framesCount,focusedFrameName,destroyed(QObject*),destroyed(),deleteLater(),initialized(),loadStarted(),loadFinished(QString),javaScriptAlertSent(QString),javaScriptConsoleMessageSent(QString),javaScriptErrorSent(QString,QString),resourceRequested(QVariant,QObject*),resourceReceived(QVariant),resourceError(QVariant),resourceTimeout(QVariant),urlChanged(QUrl),navigationRequested(QUrl,QString,bool,bool),rawPageCreated(QObject*),closing(QObject*),openUrl(QString,QVariant,QVariantMap),release(),close(),evaluateJavaScript(QString),render(QString,QVariantMap),render(QString),renderBase64(QByteArray),renderBase64(),injectJs(QString),_appendScriptElement(QString),_getGenericCallback(),_getFilePickerCallback(),_getJsConfirmCallback(),_getJsPromptCallback(),_uploadFile(QString,QStringList),sendEvent(QString,QVariant,QVariant,QString,QVariant),sendEvent(QString,QVariant,QVariant,QString),sendEvent(QString,QVariant,QVariant),sendEvent(QString,QVariant),sendEvent(QString),setContent(QString,QString),getPage(QString),childFramesCount(),childFramesName(),switchToFrame(QString),switchToChildFrame(QString),switchToFrame(int),switchToChildFrame(int),switchToMainFrame(),switchToParentFrame(),switchToFocusedFrame(),currentFrameName(),setCookies(QVariantList),cookies(),addCookie(QVariantMap),deleteCookie(QString),clearCookies(),canGoBack(),goBack(),canGoForward(),goForward(),go(int),reload(),stop()

Which matches the webpage interface.

There's probably a much nicer way to do that, but it's unbeknown to me.

Cheers

jhnns commented 10 years ago

Haha, nice. I guess, there is no other way unless the Webpage constructor is exposed somewhere and you could check for it via instanceof.

The phantomjs api is pretty rotten imho. There are some scary quirks ^^.