Code Monkey home page Code Monkey logo

celerity's People

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  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

celerity's Issues

Element#== returns false for the same page element

The following code outputs "false"

#!/usr/bin/env jruby

require "rubygems"
gem "celerity"
require "celerity"

b = Celerity::Browser.new
b.goto("http://www.google.co.uk/")
puts b.button(:text => "Google Search") == b.button(:text => "Google Search")

This caught us out because we were writing Cucumber step matchers, and the code was failing even though we were actually finding the right element. (We wanted to check that the element with input focus was the first text field in a form.)

Would it be possible to implement Element#== in terms of something with more page semantics, such as the XPath of the elements?

Bug in Browser#confirm

Hi there,

I'm getting an error when I try to call Browser#confirm -- wrong number of arguments (2 for 1), pointing to the last line. It seems that it should be listener.remove_listener(:confirm, &blk) and not listener.remove_listener(:confirm, blk).

Thanks,
-- Elliot

Remove deprecated APIs

  1. Diff watirspec master..watir2
  2. Remove deprecated APIs from Celerity's watir2-compliance branch.
  3. Add deprecation warnings where it makes sense to Celerity's master branch.

:resynchronize => true causes "java.lang.ref.WeakReference" with Marshal.dump

browser = Celerity::Browser.new :resynchronize => true, :browser => :firefox, :log_level => :off
browser.clear_cookies

browser.goto("http://www.monster.de/")
page = browser.page
file = Dir.pwd + "/page.dmp"
File.open(file, 'w') {|f| f.write(Marshal.dump(page)) }

=> `marshal_dump': java.lang.ref.WeakReference (IOError)

removing the :resynchronize => true results in the marshal dump working properly.
I guess that this has something to do with threading.

SelectList#select_value behaves differently than watir equivalent.

SUMMARY:
Celerity selects only by option label/text; watir can select by value

DESCRIPTION:
In Watir, SelectList has two methods for selecting:
select (selects by text, or label)
select_value (selects by value)

in celerity select_value is aliased to select. However, matches_option? checks the passed value only against option labels, not against option values.

EFFECT:
Tests written to select dropdown items by value (very typical in multi-language applications for example) will fail.

Embedded HTML in an iframe

When I encounter HTML in the form

    <html>
     ...
     <body>
       ...
       <iframe>
         <html>
         ...
         </html>
       </iframe>
       ...
     </body>
     ...
    </html>

and then wish to extract the stuff in the embedded HTML-document in the iframe, for example using

    browser.element_by_xpath("//iframe").innerText

...innerText returns an empty string.

Bug or feature? How are you supposed to get the embedded data?

(Mind you, I use Celerity for scraping and thus have no control over the HTML.)

Table :caption element locator

It would be great if there was a way to locate tables by caption, eg finding

<table>
    <caption>My first table</caption>
    <thead>
    ...
</table>

by writing

browser.table(:caption => "My first table")

WDYT?

Window switching API

(original title: link.click_and_attach: no way to filter through windows)

i brought this up a while back, but it seems like Celerity has no support for choosing between multiple popup or main window.

i link.click_and_attach, if the site has Popup ads, it will load the popup ad, instead of the page. browser.url will show the main page's URL. however, browser.html outputs a popup ad html.

So any way to deal with this ? i would very much prefer to use click_and_attach, and be able to filter windows (like if URL contains, ad.doubleclick, ignore it)

Is it possible to manipulate an element by multiple criteria

I am in a situation where I need to click a series of radio buttons and fill in text boxes that appear once the buttons are clicked. the problem is that they are all named the same names (both sets of buttons and text boxes). I need to click the first button, then fill in the first text box and then click the unique submit button, and repeat only with the next set of button/ boxes that are names the same.

Since they have the same name it clicks the first radio button and text box when I want it to click the 2nd, (and 3ed, and 4th) is there any way I can specify which ones I mean to click?

I need to click: <input type="radio" name="file_upload"
and: <input type="text" name="file_download_url"

for both the first and second sections, I just don't know it that is possible with celerity.

the view source code of what I need to click:
/////////////////////////////////////////////////////////////////////////////////

        <td nowrap width="100%">
            <input type="radio" name="file_upload" checked onChange="selectUploadField(true, this.form.file, this.form.file_download_url)"/> Local file
            <input type="radio" name="file_upload" onChange="selectUploadField(false, this.form.file, this.form.file_download_url)"/> URL<br>

            <input type="file" name="file" size="40">
            <input type="text" name="file_download_url" size="40" style="display:none;"><br>






                    <input type="image" name="UploadFile" value="Upload File" src="images/buttons/upload.png">


            <br>
        </td>
    </tr>
</form>

<tr>
    <td>&nbsp;</td>
</tr>
<tr>

    <td valign="top" width="100%" colspan="4">



                <strong>Upload OTA File:</strong>


        <br>

            (OTA Installation files should be CAB files for PocketPC (or EXE only if the file is compiled with Spb AirSetup), PRC files for Palm OS, SIS/SISX/JAR files for Symbian, and APK for Android.)

    </td>
</tr>
<tr>



        <form name="otaproductform" action="productfileupload.dp" method="post" enctype="multipart/form-data" onSubmit="return validOTAData();">

            <input type="hidden" name="productId" value="303554">
            <input type="hidden" name="whichJspFile" value="productfileupload.dp">

            <td class="label-column">Upload OTA File:</td>
            <td>
                <input type="radio" name="file_upload" checked onChange="selectUploadField(true, this.form.file, this.form.file_download_url)"/> Local file
                <input type="radio" name="file_upload" onChange="selectUploadField(false, this.form.file, this.form.file_download_url)"/> URL<br>
                <input type="file" name="file" size="40">

                <input type="text" name="file_download_url" size="40" style="display:none;"><br>



                        <input type="image" name="UploadOTAFile" value="Upload File" src="images/buttons/upload.png">


            </td>
        </form>

///////////////Thank you for your time and help!

proxy with authentication

Is there any way to use celerity wtih proxy that uses authentication.
I just need setup login and password for Celerity::Browser.

Unable to open www.yahoo.com in default/firefox mode!

On opening the website "http://www.yahoo.com" in default or firefox or firefox3 mode the website is not opened properly. However when I open it in internet_explorer mode the website opens properly.
I am using the latest version 0.8.7.

Here is the sample code:

require "rubygems"
require "celerity"
br = Celerity::Browser.new()
br.goto("http://www.yahoo.com")
puts br.html

Expected Output: The entire source code of the website

Actual Output: Just 1 line

which is actually just the last line of the source code of the site.
However if I open it in internet_explorer mode

require "rubygems" require "celerity" br = Celerity::Browser.new(:browser => :internet_explorer) br.goto("http://www.yahoo.com") puts br.html It functions as expected and the complete site is available.

3 specs failing with "ERROR ArgumentError: negative length -39 given" or similar

I'm seeing 3 specs fail due to WEBrick raising an exception and returning a 500 error:

I'm also seeing a 4th spec fail, but it is probably an unrelated issue:

Info about my environment:

  • "jruby --version" output:

    jruby 1.5.1 (ruby 1.8.7 patchlevel 249) (2010-06-06 f3a3480) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_20) [x86_64-java]

  • Mac OS X 10.6.4

  • "uname -a" output:

    Darwin atocha.local 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386

  • standard Ruby 1.8.7

  • "java -version" output:

    java version "1.6.0_20"
    Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
    Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode)

Finally, here's the verbose output of a full run ("jruby -S spec -f s --backtrace spec"):

Let me know if I can gather any more info to help.

Cheers,
Wincent

How to get intermediates pages during redirection 302

Hi,

For instance, I have something like :

br= Celerity::Browser.new

br.goto foo

and br.url gives bar because foo redirect to bar.
I wish to parse also the body of page foo.

If i set a listener on :web_window_event I receive something like :

WebWindowEvent(source=[TopLevelWindow[name=""]] type=[CHANGE] oldPage=[null] newPage[HtmlPage(bar)@920503681]

Regards

'script' tags should be handled

There should be a collection for '<script>' tags. Right now you can find them but you have to use the elements_by_xpath method.

com.gargoylesoftware.htmlunit.ObjectInstantiationException: unable to create HTML parser (NativeException)

I've just installed the follow gem versions on JRuby 1.6.4:

capybara (1.0.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (> 2.0)
xpath (
> 0.1.4)
capybara-celerity (0.0.1)
capybara (>= 0.4.1)
celerity (>= 0.7.9)
celerity (0.9.0)

and get the error: "com.gargoylesoftware.htmlunit.ObjectInstantiationException: unable to create HTML parser (NativeException)"

which seems to cause the following error for each case:

"java.lang.NullPointerException: No document element ("

Any ideas?

Cheers,
Matt

Update to latest HtmlUnit snapshot to fix URL encoding bug

I originally posted to the mailing list here:

http://rubyforge.org/pipermail/celerity-users/2010-June/000394.html

describing a problem with the "goto()" method wherein special characters in the URL were getting mangled (double-encoded) and thus producing spurious 404 errors.

Doing by hand in "jirb" what Celerity is doing behind the scenes, I was able to show that it is the version of HtmlUnit that ships with Celerity which is responsible for the double-escaping:

$ jirb -r rubygems -r celerity
> url = Java::JavaNet::URL.new 'http://localhost:3000/wiki/has_%3Cstrange%3E_stuff'
> request = HtmlUnit::WebRequestSettings.new url
> client = HtmlUnit::WebClient.new HtmlUnit::BrowserVersion::FIREFOX_3
> client.getPage request

In the server logs, the request is being sent to "/wiki/has_%25253Cstrange%25253E_stuff", which doesn't exist. The "%" is becoming "%25", which is in turn being escaped again and becoming "%2525".

Searching on the HtmlUnit tracker I found a number of bugs related to this double-encoding.

That last one suggests that the bug is fixed in the latest HtmlUnit snapshot available from here:

http://build.canoo.com/htmlunit/artifacts

So as a quick-and-dirty test, I replaced the version of HtmlUnit that ships with Celerity in my local install with the latest snapshot:

$ cd /usr/local/jruby/lib/ruby/gems/1.8/gems/celerity-0.7.9/lib/celerity/htmlunit
$ sudo rm *.jar
$ sudo curl -O http://build.canoo.com/htmlunit/artifacts/htmlunit-2.8-SNAPSHOT-with-dependencies.zip
$ sudo unzip htmlunit-2.8-SNAPSHOT-with-dependencies.zip 
$ sudo mv htmlunit-2.8-SNAPSHOT/lib/* .

And then repeated my original tests; the URL double-encoding bug is now fixed.

So, that's what this ticket is about: a request to update to the latest snapshot of HtmlUnit so that URLs with "special" characters in them can be accessed.

Unfortunately there is no workaround other than updating HtmlUnit. Passing in an unencoded URL (ie. with literal "<" and ">" characters) doesn't work because it still ends up getting double-encoded (ie. as "/wiki/has_%253Cstrange%253E_stuff") which will also produce spurious 404 errors.

Cheers,
Wincent

Invalid gemspec warning during "bundle install", "bundle update"

Not sure if there's anything that can be done about this one but I am seeing messages like this when doing "bundle install" or "bundle update" with Bundler 1.0.0.beta.2 and RubyGems 1.3.7 on Mac OS X 10.6.4:

Using celerity (0.7.9) from git://github.com/jarib/celerity.git (at master) 
celerity at /Users/wincent/.bundle/bundler/gems/celerity-f7a0796 did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
  ["lib/celerity/htmlunit/commons-httpclient-3.1.jar", "lib/celerity/htmlunit/htmlunit-2.7-SNAPSHOT.jar", "lib/celerity/htmlunit/htmlunit-core-js-2.7-SNAPSHOT.jar", "lib/celerity/htmlunit/nekohtml-1.9.14-20100122.114035-12.jar"] are not files

The line in my Gemfile that I'm using is:

gem 'celerity', :require => nil, :git => 'git://github.com/jarib/celerity.git'

I think I started seeing these messages when I switched to the Git version of Celerity. Didn't see them in the last released gem.

Cheers,
Wincent

getRows is undefined for Table Element

When verifying if a table exist or if it's visible, the following error message is returned from jruby:

C:/Program Files/jruby-1.4.0/lib/ruby/gems/1.8/gems/celerity-0.7.9/lib/celerity/
elements/table.rb:25:in locate': undefined methodgetRows' for # (NoMethodError)
from C:/Program Files/jruby-1.4.0/lib/ruby/gems/1.8/gems/celerity-0.7.9/
lib/celerity/element.rb:174:in assert_exists' from C:/Program Files/jruby-1.4.0/lib/ruby/gems/1.8/gems/celerity-0.7.9/ lib/celerity/element.rb:186:inexists?'

socketConnect': java.net.ConnectException: Connection refused (NativeException)

java/net/PlainSocketImpl.java:-2:in socketConnect': java.net.ConnectException: Connection refused (NativeException) from java/net/AbstractPlainSocketImpl.java:310:indoConnect'
from java/net/AbstractPlainSocketImpl.java:176:in connectToAddress' from java/net/AbstractPlainSocketImpl.java:163:inconnect'
from java/net/SocksSocketImpl.java:384:in connect' from java/net/Socket.java:546:inconnect'
from sun/security/ssl/SSLSocketImpl.java:570:in connect' from sun/security/ssl/SSLSocketImpl.java:414:in'
from sun/security/ssl/SSLSocketFactoryImpl.java:142:in createSocket' ... 16 levels... from ./main.rb:212 from ./main.rb:208:ineach'
from ./main.rb:208

211 aimb = Celerity::Browser.new(:resynchronize => true)
212 aimb.goto(AIM_LOGIN)

Unable to submit form using the action attribute

I'm trying to run a few tests using cucumber & celerity

The HTML code is a as follows:

All Articles Blogs Videos Slideshows Podcasts

I'm trying to submit the form using the following
@browser.form(:action,'/search').submit

And I get the following error
undefined method `submit' for #Celerity::Form:0xd9d6ae

No way to disable JavaScript

HtmlUnit allows you to disable JavaScript with WebClient.setJavaScriptEnabled(false). The only way to do this in Celerity is browser.webclient.java_script_enabled = false.

I think this should be a Celerity::Browser constructor option and also a setter (so you can turn it on and off part way through a test).

Clicking link with URL-encoded href fails (double-encoding)

When I call click on a link which has a URL-encoded href (eg a link to a URL containing spaces encoded as %20), celerity appears to re-encode the URL, so for example "foo%20bar" becomes "foo%2520bar".

This was working OK in 0.7.3, but seems to have broken in 0.7.4. I'm not sure whether it's an issue with Celerity itself, or with htmlunit.

The issue can be reproduced with the following code:

require "rubygems"
require "celerity"

browser = Celerity::Browser.new
browser.goto('http://localhost/celerity_test.html')

browser.link(:text, 'Another page').click
puts browser.text

'celerity_test.html' contains the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head><title>Celerity Test</title></head>
  <body>
    <p>
      <a href="another%20page.html">Another page</a>
    </p>
  </body>
</html>

'another page.html' just needs to have some content to indicate that it's the right page.

I tried to create a patch (or at least a failing spec), but doing something similar to the above from within a spec seemed to work OK. Maybe it's fixed in master.

Container#td as alias for Container#cell

It would be useful if you could access table cells via a Container#td method. Every single time I access table cells I write td and wonder why it doesn't work.

It could display a warning or something if the reason for this is Watir-compatibility.

Small leak: browser doesn't clear all references

In method Browser::page= there is a field @object assigned when Page is get. This field isn't cleared when you call Browser::close method. There should be '@object = nil' statement added in close method.

I've run into this problem running suite with hundred test cases. Each test case uses new Browser created in setup that is closed in teardown. But I've run into OutOfMemory exception as browsers keeped references to huge objects. When you add '@object = nil' to close method - you nullify reference to huge @object and heap can clean itself.

Trouble with https via the proxy

I am testing a web application ( www.tradingpost.com.au ) using Cucumber and Celerity 0.9.0 and the test sites for the application are on a lcoal intranet. I am a strong fan of Celerity . . . its a great product for testing web apps

I need to test using https as login and credit card collection is an essential component of system behaviour and I also need a proxy as parts of the system reference external sites. I can run without but miss javascript loads and also suffer excessive times outs

I am finding that the HtmlUnit proxy bypass does not consistently work with https. It seems that only the very first request after browser instantiantion for https is served correctly

This is more an HTMLUnit issue than a Celerity issue but all my code and examples are Celerity

If I set up the browser with this method

def new_browser( host_to_bypass )
browser = Celerity::Browser.new(
:proxy => "tpg-proxy.corp1.local:8080",
:resynchronize => true,
:log_level => :severe)
browser.webclient.setUseInsecureSSL(true)
browser.webclient.java_script_enabled = false
if host_to_bypass
proxyconfig=browser.webclient.getProxyConfig()
proxyconfig.addHostsToProxyBypass(host_to_bypass)
end
browser
end

When if I do some tests

require 'rubygems'
require 'Celerity'
#1. Just https

browser=new_browser ('10.169.142.33')

browser.goto "https://10.169.142.33/Home"
puts browser.status_code
200
browser.goto "https://10.169.142.33/Home"
puts browser.status_code
504
#2. Just http: in same session ( and aslo after restarting jruby and loading gems )

browser=new_browser ('10.169.142.33')
browser.goto "http://10.169.142.33/Home"
puts browser.status_code
200
browser.goto "http://10.169.142.33/Home"
puts browser.status_code
200

. . . and so on as often as I please

#3 just http: then https:

browser=new_browser ('10.169.142.33')
browser.goto "http://10.169.142.33/Home"
puts browser.status_code
200
browser.goto "https://10.169.142.33/Home"
puts browser.status_code
504
#4 https: external then internal

browser=new_browser ('10.169.142.33')
browser.goto "https://www.google.com.au"
puts browser.status_code
200
browser.goto "https://10.169.142.33/Home"
puts browser.status_code
504
#5 https https: extenal then internal

browser=new_browser ('10.169.142.33')
browser.goto "https://10.169.142.33/Home"
puts browser.status_code
200
browser.goto "https://www.google.com.au"
puts browser.status_code
200

This is quite a problem as it only allows a smal part of the system to be tested

Any advice on how where when to correct, any advice on where better to seek advice or even pointers to the correct code in html unit appreciated

thanks in advance
Matthew B

error render facebook like button iframe

Not work facebook script http://connect.facebook.net/en_US/all.js

======= EXCEPTION START ========
Exception class=[java.lang.RuntimeException]
com.gargoylesoftware.htmlunit.ScriptException: Exception invoking jsxFunction_submit
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:604)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:534)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:897)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptFunctionJob.runJavaScript(JavaScriptFunctionJob.java:53)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutionJob.run(JavaScriptExecutionJob.java:84)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runJob(JavaScriptJobManagerImpl.java:223)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:304)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutor.run(JavaScriptExecutor.java:180)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Exception invoking jsxFunction_submit
at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:198)
at net.sourceforge.htmlunit.corejs.javascript.FunctionObject.call(FunctionObject.java:479)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1702)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:845)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:429)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:267)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3162)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:562)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:527)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:598)
... 10 more
Caused by: java.lang.IllegalArgumentException: Not a valid url: ?container=friendconnect&mid=1&nocache=0&view=profile&parent=http%3A%2F%2Fvasilec.blogspot.com%2F&url=http%3A%2F%2Fwww.google.com%2Ffriendconnect%2Fgadgets%2Fmembers.xml&communityId=09395838815351334155&caller=http%3A%2F%2Fvasilec.blogspot.com%2F2010%2F12%2Fspree-webmoney.html&rpctoken=1415726414&locale=ru
at com.gargoylesoftware.htmlunit.html.HtmlForm.getWebRequest(HtmlForm.java:217)
at com.gargoylesoftware.htmlunit.javascript.host.html.HTMLFormElement.jsxFunction_submit(HTMLFormElement.java:264)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:172)
... 21 more
Enclosed exception:
java.lang.RuntimeException: Exception invoking jsxFunction_submit
at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:198)
at net.sourceforge.htmlunit.corejs.javascript.FunctionObject.call(FunctionObject.java:479)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1702)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:845)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:429)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:267)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3162)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:562)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:527)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:598)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:534)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:897)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptFunctionJob.runJavaScript(JavaScriptFunctionJob.java:53)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutionJob.run(JavaScriptExecutionJob.java:84)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runJob(JavaScriptJobManagerImpl.java:223)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:304)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutor.run(JavaScriptExecutor.java:180)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Not a valid url: ?container=friendconnect&mid=1&nocache=0&view=profile&parent=http%3A%2F%2Fvasilec.blogspot.com%2F&url=http%3A%2F%2Fwww.google.com%2Ffriendconnect%2Fgadgets%2Fmembers.xml&communityId=09395838815351334155&caller=http%3A%2F%2Fvasilec.blogspot.com%2F2010%2F12%2Fspree-webmoney.html&rpctoken=1415726414&locale=ru
at com.gargoylesoftware.htmlunit.html.HtmlForm.getWebRequest(HtmlForm.java:217)
at com.gargoylesoftware.htmlunit.javascript.host.html.HTMLFormElement.jsxFunction_submit(HTMLFormElement.java:264)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:172)
... 21 more
== CALLING JAVASCRIPT ==

function () {
fc5.H(b);
}

======= EXCEPTION END ========

Javascript Execution Hangs - Need help

Hello,

We are using Celerity (JRuby wrapper around Watir, using HtmlUnit as the underlying browser) to navigate thru the webpage, (https://www.sos.ok.gov/corp/bulkorder/bulkDefault.aspx). We have encountered an issue with java script on this webpage.

Javascript execution hangs when we try to access the URL https://www.sos.ok.gov/cart/contact.aspx?ReturnUrl=/corp/bulkorder/bulkEntry.aspx by clicking the "Place order" link on https://www.sos.ok.gov/corp/bulkorder/bulkDefault.aspx'

Using java script debugger we found that JS hangs at this piece of code.

if (!ValidatedTextBoxOnKeyPress(event)) { event.cancelBubble = true; if (event.stopPropagation) event.stopPropagation();
return false; }

Also attached the entire java script file (okjs.txt)

Javascript needs to be enabled to navigate through this website. So we can't disable javascript in this case.
Also java script timeout doesnt seem to be working here.
Is this a bug in htmlunit?

Here is the code for your reference.

require 'rubygems'
require 'celerity'
proxyProtocol, proxyHost, proxyPort = ENV["http_proxy"].split(':')
proxyHost = proxyHost.scan(%r"//(.*)")[0][0]
browser = Celerity::Browser.new( { :browser => :firefox3, :proxy => proxyHost + ':' + proxyPort } )
browser.webclient.setJavaScriptEnabled(true)
browser.css = false
browser.secure_ssl = false

HtmlUnit::Util::WebClientUtils.attachVisualDebugger(browser.webclient)

browser.goto 'https://www.sos.ok.gov/corp/bulkorder/bulkDefault.aspx' ### This works alright.
browser.wait
puts "clicking Place Order"
browser.button(:id,'ctl00_DefaultContent_buttonSubmit').click ### Here's where it hangs
browser.wait
puts browser.html

Thanks
Vamsee.

pixel tracking with celerity

Is it possible to monitor asynchronous calls to other servers? For example, I want to test to make sure our API is being properly implemented on a partner site: 'notify' signals are to be sent to my company's site. I want to log that their JQuery is generatign the 'notify' signals. There are no changes to the browser. The signal is just a request for a pixel on my company's server with a bunch of GET params set which contains all the tracking info. Is this possible to test using Celerity?

Hanging at end of spec run

Trying out the 0.8.0 beta and I'm seeing my spec runs hang indefinitely whenever Celerity is involved. Here's a couple of samples:

$ rspec spec/acceptance/sessions_spec.rb 
.......


Finished in 13.59 seconds
7 examples, 0 failures
^C
$ rspec spec/acceptance/regressions/76968b7_spec.rb 
..


Finished in 9.27 seconds
2 examples, 0 failures
^C

So basically any spec just sits there after completing, until I Control-C it.

I did some high-tech debugging via logging and found that the rspec run just hanging in the "at_exit" handler forever, right after the call to exit(); here you can see my modified version that I added so I could see what was happening:

at_exit {
  begin
    run(ARGV, $stderr, $stdout) ? exit(0) : exit(1)
  rescue Exception => e
    puts e.inspect
    puts e.backtrace
    raise e
  end
}

The specs run, we do "exit(0)", my "rescue" catches the exception (it's a SystemExit exception), logs it, re-raises it, and absolutely nothing happens...

Cheers,
Wincent

Browser#new(:css => false) causes ArgumentError

ArgumentError: unknown option {:css=>false}

The culprit is line 856 of browser.rb:

self.css = opts.delete(:css) if opts[:css]

which fails to delete the entry out of opts as the value is false, thus failing the if condition

consider the following as a fix:
self.css = opts.delete(:css) if opts.include?(:css)

ins tag support

The ins tag (for inserted text) is supported by HtmlUnit but not Celerity. I have a fork of Celerity with support for the ins tag added. I'm not sure if it needs tests, it doesn't look like every single element has tests. But if I'm missing something, please let me know. Here's the branch link.

http://github.com/centraldesktop/celerity/commits/add_ins

Thanks!

Exception: org.apache.http.NoHttpResponseException

When I run my tests using cucumber/celerity I dont see any errors in my output file, however I see the following. all my tests are doing is just clicking through a bunch of links and navigating.

C:\my_tests>jruby -S cucumber --format html --out=results.html
Nov 4, 2010 12:42:17 PM org.apache.http.impl.client.DefaultRequestDirector execute
INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request: The target server failed to respond
Nov 4, 2010 12:42:17 PM org.apache.http.impl.client.DefaultRequestDirector execute
INFO: Retrying request

does anyone know what is happening? Can I safely ignore this?

Using Array Index in Table causes ArrayIndexOutOfBoundsException

Trying to find values with an array index inside a table fails with an ArrayIndexOutOfBoundsException.

table = @browser.table(:index, 0)
table[0][0].text

Causes the following:

NativeException: java.lang.ArrayIndexOutOfBoundsException: -1
java/util/ArrayList.java:324:in `get'
java/util/Collections.java:1154:in `get'
sun/reflect/NativeMethodAccessorImpl.java:-2:in `invoke0'
sun/reflect/NativeMethodAccessorImpl.java:39:in `invoke'
sun/reflect/DelegatingMethodAccessorImpl.java:25:in `invoke'
java/lang/reflect/Method.java:597:in `invoke'
org/jruby/javasupport/JavaMethod.java:525:in `invokeDirectWithExceptionHandling'
C:/jruby-1.6.1/lib/ruby/site_ruby/shared/builtin/java/java.util.rb:82:in `[]'

Can I emulate a specific browser?

Is there any way when creating a Celerity connection that I can present myself as a specific browser to the server (in effect tweaking the user agent)? I have a web app that requires IE 7/8 or Firefox 3.x, so it is failing when I connect using Celerity.

Thanks.

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.