jarib / celerity Goto Github PK
View Code? Open in Web Editor NEWThis project is no longer maintained.
Home Page: http://celerity.rubyforge.org/
License: GNU General Public License v2.0
This project is no longer maintained.
Home Page: http://celerity.rubyforge.org/
License: GNU General Public License v2.0
including section, aside, nav, address, time, progress:
Use http://html5doctor.com/glossary/ as a reference
See the latest change in my branch for the fix.
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?
http://github.com/jarib/celerity/blob/master/lib/celerity/browser.rb#L533 - at this line remove_listener is called with block rather than passing it as second argument:
http://github.com/jarib/celerity/blob/master/lib/celerity/listener.rb#L52
Failing specs for this.
Browser#send_keys can only type characters that matches regexp \w, which means it cannot send ".", "@" or a bunch of other useful characters.
Failing spec in select_list_spec.rb
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
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)) }
removing the :resynchronize => true results in the marshal dump working properly.
I guess that this has something to do with threading.
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.
Both for locating elements and getting the attribute off an element.
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.)
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?
(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)
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> </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!
It would be nice to be able to use xpath on a subset of a page. Any specific reason why this isn't included?
Is there any way to use celerity wtih proxy that uses authentication.
I just need setup login and password for Celerity::Browser.
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.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
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
There should be a collection for '<script>' tags. Right now you can find them but you have to use the elements_by_xpath method.
i.e. <option>Text</option>
#value
should return nil
in this situation, not ''
. Otherwise there's no way to distinguish <option value=''>Text</option>
.
The underlying HtmlUnit method hasAttribute
correctly returns false.
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)> 0.1.4)
xpath (
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
browser.divs(:class => "foo") #=> DivCollection
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
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
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 method
getRows' 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:in
exists?'
java/net/PlainSocketImpl.java:-2:in socketConnect': java.net.ConnectException: Connection refused (NativeException) from java/net/AbstractPlainSocketImpl.java:310:in
doConnect'
from java/net/AbstractPlainSocketImpl.java:176:in connectToAddress' from java/net/AbstractPlainSocketImpl.java:163:in
connect'
from java/net/SocksSocketImpl.java:384:in connect' from java/net/Socket.java:546:in
connect'
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:in
each'
from ./main.rb:208
211 aimb = Celerity::Browser.new(:resynchronize => true)
212 aimb.goto(AIM_LOGIN)
I'm trying to run a few tests using cucumber & celerity
The HTML code is a as follows:
All Articles Blogs Videos Slideshows PodcastsI'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
The forum should not submit because of either the event.preventDefault() or by returning false. In real safari or firefox, this works ( see http://uiuc.us/jquery.html ), but when the browser on htmlunit is set to firefox, the forum submits and goes to google. When it is set to internet_explorer, it works correctly.
I'm not sure if this is a bug in celerity or htmlunit itself.
According to HISTORY:
== 0.0.6 2009-03-19
...
However, the Getting started page still has a "Show methods" section.
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).
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.
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.
As per discussion on the mailing list, a possible simplification of the element finder methods for unique elements. For example:
@table.thead.cells
as a shorthand for either of:
@table.thead(:index => 1).cells
@table.theads.first.cells
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.
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
#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
Element#parent spec is failing.
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 ========
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
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.
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?
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
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)
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!
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?
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 `[]'
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.