From phillipkoebbe at gmail.com Sat Jan 9 10:15:17 2010 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Sat, 09 Jan 2010 09:15:17 -0600 Subject: [Celerity-users] focused_element.id error Message-ID: <4B489D85.9000602@gmail.com> This is my first post to this community. I'd like to start by saying 'Great work!' I am a relative newcomer to the testing world, and have recently started using Cucumber, Culerity/Celerity, and RSpec, and am having a great time! On to my problem: I am asking on the celerity list because it looks like the error is originating with celerity and culerity is just passing it along. The environment: ruby 1.8.7 (2008-08-11 patchlevel 72) culerity (0.2.6) cucumber (0.6.1, 0.5.3) cucumber-rails (0.2.3, 0.2.2) jruby 1.4.0 (ruby 1.8.7 patchlevel 174) celerity (0.7.6) The issue: browser.focused_element.id returns the id of the element that has the focus. However, focused_element = browser.focused_element focused_element.id does not. Instead, I get this error: Culerity::CulerityException Exception: Celerity::Exception::UnknownObjectException: Unable to locate Element, using :object and nil Is this a feature or a bug, or something in between? Peace, Phillip From jari.bakken at gmail.com Sat Jan 9 10:23:57 2010 From: jari.bakken at gmail.com (Jari Bakken) Date: Sat, 9 Jan 2010 16:23:57 +0100 Subject: [Celerity-users] focused_element.id error In-Reply-To: <4B489D85.9000602@gmail.com> References: <4B489D85.9000602@gmail.com> Message-ID: It would be helpful if you could create a minimal test case that lets us reproduce the error, using Celerity alone. Assigning the element to a variable should make no difference. From phillipkoebbe at gmail.com Sat Jan 9 11:04:10 2010 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Sat, 09 Jan 2010 10:04:10 -0600 Subject: [Celerity-users] focused_element.id error In-Reply-To: References: <4B489D85.9000602@gmail.com> Message-ID: <4B48A8FA.2040203@gmail.com> Jari Bakken wrote: > It would be helpful if you could create a minimal test case that lets > us reproduce the error, using Celerity alone. Assigning the element to > a variable should make no difference. > _______________________________________________ > Celerity-users mailing list > Celerity-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/celerity-users > Hi Jari, Thanks for the quick response. I would be happy to submit a test case. Is there a guide posted somewhere that could help me do that? As I mentioned, I'm relatively new to the testing party, and while I understand how to spec in a Rails project, I'm not sure how to test a gem. And I have no direct experience with JRuby at all. I only followed the instructions for installing Culerity. Regarding the error, after I sent the message, I was investigating some more via the debugger, and I'm a bit baffled by what I'm seeing. Even without assigning to a variable, when I run the scenario straight through (without stopping in the debugger), it fails with the error. But if I stop in the debugger and inspect the participating players, everything is fine and when I continue, the step passes. So it seems there is some timing issue at work, but I can't put my finger on what it is. [imagine the sound of a ticking clock...] I just did another little experiment using sleep(), and I discovered that if I wait for 0.7 second or more, the step passes. Here's the relevant code: return false if browser.focused_element.nil? sleep(0.7) return browser.focused_element.id == get_element(type, what, how).id [get_element is my own wrapper around the browser.element methods.] Values less than 0.7 resulted in failure, but 0.7 and up didn't. Peace, Phillip From jari.bakken at gmail.com Sat Jan 9 11:20:34 2010 From: jari.bakken at gmail.com (Jari Bakken) Date: Sat, 9 Jan 2010 17:20:34 +0100 Subject: [Celerity-users] focused_element.id error In-Reply-To: <4B48A8FA.2040203@gmail.com> References: <4B489D85.9000602@gmail.com> <4B48A8FA.2040203@gmail.com> Message-ID: On Sat, Jan 9, 2010 at 5:04 PM, Phillip Koebbe wrote: > > Hi Jari, > > Thanks for the quick response. I would be happy to submit a test case. Is > there a guide posted somewhere that could help me do that? As I mentioned, > I'm relatively new to the testing party, and while I understand how to spec > in a Rails project, I'm not sure how to test a gem. And I have no direct > experience with JRuby at all. I only followed the instructions for > installing Culerity. There's no detailed guide, but if you can provide me with some example HTML + Ruby code that I can run to reproduce the issue, that will help a lot. Otherwise you can check out Celerity from GitHub and look at the spec/ folder (and the WatirSpec git submodule) to see how Celerity is tested. > > I just did another little experiment using sleep(), and I discovered that if > I wait for 0.7 second or more, the step passes. Here's the relevant code: > > ? ?return false if browser.focused_element.nil? The if condition here will never be true - Browser#focused_element will always return a kind of Celerity::Element. Perhaps it should be changed to raise an exception if no element has the focus. > ? ?sleep(0.7) > ? ?return browser.focused_element.id == get_element(type, what, how).id > > [get_element is my own wrapper around the browser.element methods.] Values > less than 0.7 resulted in failure, but 0.7 and up didn't. Yes, sounds like the DOM is changing under your feet. Instead of sleeping you should wait until the element exists before trying to interact with it - we have some helper methods to do that: - Browser#wait_while - Browser#wait_until > > Peace, > Phillip > _______________________________________________ > Celerity-users mailing list > Celerity-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/celerity-users > From phillipkoebbe at gmail.com Sat Jan 9 11:49:43 2010 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Sat, 09 Jan 2010 10:49:43 -0600 Subject: [Celerity-users] focused_element.id error In-Reply-To: References: <4B489D85.9000602@gmail.com> <4B48A8FA.2040203@gmail.com> Message-ID: <4B48B3A7.70806@gmail.com> Jari Bakken wrote: > On Sat, Jan 9, 2010 at 5:04 PM, Phillip Koebbe wrote: > > There's no detailed guide, but if you can provide me with some example > HTML + Ruby code that I can run to reproduce the issue, that will help > I will work on that later today. Thanks for the willingness! > a lot. Otherwise you can check out Celerity from GitHub and look at > the spec/ folder (and the WatirSpec git submodule) to see how Celerity > is tested. > > I might want to do that anyway! > The if condition here will never be true - Browser#focused_element > will always return a kind of Celerity::Element. > That's good to know. I took out the "return if nil?" line. > Perhaps it should be changed to raise an exception if no element has the focus. > > >> sleep(0.7) >> return browser.focused_element.id == get_element(type, what, how).id >> >> [get_element is my own wrapper around the browser.element methods.] Values >> less than 0.7 resulted in failure, but 0.7 and up didn't. >> > > Yes, sounds like the DOM is changing under your feet. Instead of > sleeping you should wait until the element exists before trying to > interact with it - we have some helper methods to do that: > > - Browser#wait_while > - Browser#wait_until > > I didn't want to dump too much code on you at first, so I included only what I thought to be relevant. The actual path of execution is here: http://gist.github.com/272979 I have wrappers for many operations (think code reuse), and I do check for existence before checking to see if it's focused. At the top of the gist are the steps in the scenario, all of which pass prior to checking the focused state. So not only do I check to make sure the element is on the page prior to checking for it having focus, I have already checked to make sure it is empty, which also checks to make sure it is there first. I wish you a great day/night (whatever it is in your part of the world)! Peace, Phillip From phillipkoebbe at gmail.com Tue Jan 12 09:31:50 2010 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Tue, 12 Jan 2010 08:31:50 -0600 Subject: [Celerity-users] focused_element.id error In-Reply-To: <4B48B3A7.70806@gmail.com> References: <4B489D85.9000602@gmail.com> <4B48A8FA.2040203@gmail.com> <4B48B3A7.70806@gmail.com> Message-ID: <4B4C87D6.103@gmail.com> I wanted to take a moment to bring everyone up to date. I sent a sample project to Jari off-list, the outcome of which was the element was not focused at the time that I called Browser#focused_element. Here is something of a transcript of our exchange: ==================================================== Jari: The problem is that the element doesn't have focus - not even in real browsers. I added a script tag that adds focus on load, and the test passes. I'll change Browser#focused_element so it will raise a more obvious error if no element has focus. Me: Thanks, Jari. That's actually why I originally had the "return if nil?" bit. I was expecting that there wouldn't be an element returned if no element had focus. If I might offer my opinion, I don't think raising an exception here is the right thing to do. Consider the finder methods. When I do a $browser.text_field(:id, 'my_field'), I get an element back whether there is actually one in the DOM or not. To determine if it is actually there, I must then call .exists? It seems that in the case of browser.focused_element an error would be inconsistent. Maybe either return an element with no exception and require the user to check exists? like the other finders, or just return nil. Jari: Good points. I agree that it's more consistent with the finder methods, on the other hand it doesn't really make sense to call #focused_element unless you expect some element to have focus, thus no element having focus is sort of exceptional. Perhaps I'm just influenced by working on WebDriver though, where use of exceptions in these cases is a lot more common. Anyone else want to chime in? I've reverted the change for now. Perhaps adding Element#focus? (or Element#focused?) would also be a good idea. Me: I would like Element#focused?. In fact, that was the first thing I looked for and was surprised it wasn't there. I'm a believer in the Principle of Least Surprise, though. ==================================================== I would also like to add another thought. RE Jari's statement: it doesn't really make sense to call #focused_element unless you expect some element to have focus True, but on the other hand (is this the third hand now?), we don't call finders unless we expect the elements to be there. In the case of testing, especially testing first, our tests are establishing expectations that we know are satisfied when the code does what it is supposed to. To raise an exception is probably the right thing to do, but more important to me is consistency. If we don't get an error in a finder, we shouldn't get one here. On the other hand (the fourth!), I agree with the "raising an exception" principle so much that I've written wrappers around the finders so I can raise an exception if the element doesn't exist. For instance: element_should_exist(type, what, how = :id) raise UnmetExpectation, unless element_exists?(type, what, how) end element_should_not_exist(type, what, how = :id) raise UnmetExpectation, if element_exists?(type, what, how) end where element_exists? is a wrapper around the Browser finder methods. Hm. Now that I think about it, maybe I wouldn't want Celerity to raise exceptions. I think I prefer checking a boolean and deciding what to do with it myself. Okay, I just convinced myself that I would prefer no exception. And the #focused method, of course! Peace, Phillip From phillipkoebbe at gmail.com Tue Jan 12 15:59:40 2010 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Tue, 12 Jan 2010 14:59:40 -0600 Subject: [Celerity-users] Select multiple options of a select_list Message-ID: <4B4CE2BC.7010600@gmail.com> How can I select multiple options in a select_list? I have a select_list with multiple==true, but can't clearly see how to select multiple options. I'm looking at Browser#send_keys, but noticed a comment that says it is experimental and might be removed. I looked at SelectList#select and #select_value, but both of those expect a string to match against a label or text value. I will have multiple text values. Ideally, #select would be able to handle an array and no keystroke monkey business would be necessary. Peace, Phillip From jari.bakken at gmail.com Tue Jan 12 16:25:04 2010 From: jari.bakken at gmail.com (Jari Bakken) Date: Tue, 12 Jan 2010 22:25:04 +0100 Subject: [Celerity-users] Select multiple options of a select_list In-Reply-To: <4B4CE2BC.7010600@gmail.com> References: <4B4CE2BC.7010600@gmail.com> Message-ID: On Tue, Jan 12, 2010 at 9:59 PM, Phillip Koebbe wrote: > How can I select multiple options in a select_list? I have a select_list > with multiple==true, but can't clearly see how to select multiple options. > I'm looking at Browser#send_keys, but noticed a comment that says it is > experimental and might be removed. I looked at SelectList#select and > #select_value, but both of those expect a string to match against a label or > text value. I will have multiple text values. Ideally, #select would be able > to handle an array and no keystroke monkey business would be necessary. > Call SelectList#select multiple times, or pass a Regexp %w[foo bar baz].each { |opt| select_list.select(opt) } select_list.select /foo|bar|baz/ Same applies to SelectList#select_value. From phillipkoebbe at gmail.com Tue Jan 12 22:29:11 2010 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Tue, 12 Jan 2010 21:29:11 -0600 Subject: [Celerity-users] Select multiple options of a select_list In-Reply-To: References: <4B4CE2BC.7010600@gmail.com> Message-ID: <4B4D3E07.6060604@gmail.com> Jari Bakken wrote: > On Tue, Jan 12, 2010 at 9:59 PM, Phillip Koebbe wrote: > > Call SelectList#select multiple times, or pass a Regexp > %w[foo bar baz].each { |opt| select_list.select(opt) } > select_list.select /foo|bar|baz/ > > Same applies to SelectList#select_value. > > Thanks, Jari! Works nicely. Might this bit of info make it into the docs somewhere? Or is it there and I just missed it? Phillip From phillipkoebbe at gmail.com Sat Jan 16 12:09:19 2010 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Sat, 16 Jan 2010 11:09:19 -0600 Subject: [Celerity-users] Javascript Confirm Message-ID: <4B51F2BF.60109@gmail.com> I'm trying to respond to a javascript confirm, and so far, I have this: Given I intend to respond to the confirm with 'OK' When I click the delete_payee.id link where the Given is defined as: Given /^I intend to respond to the confirm with [']([^' ]+)[']$/ do |button| browser.add_listener(:confirm) { button == 'OK' } end and the When clicks a link that is defined (in Rails) as link_to '[Delete]', payee_path(payee), :method => :delete, :confirm => 'Are you sure?', :id => "delete_payee_#{payee.id}", :class => :delete_link But on the click of the link, I get: NativeException: com.gargoylesoftware.htmlunit.ScriptException: Exception invoking jsxFunction_confirm Is this the correct way to do this? If not, what is? If so, how can I avoid this error? Thanks, Phillip From jari.bakken at gmail.com Sat Jan 16 12:34:59 2010 From: jari.bakken at gmail.com (Jari Bakken) Date: Sat, 16 Jan 2010 18:34:59 +0100 Subject: [Celerity-users] Javascript Confirm In-Reply-To: <4B51F2BF.60109@gmail.com> References: <4B51F2BF.60109@gmail.com> Message-ID: On Sat, Jan 16, 2010 at 6:09 PM, Phillip Koebbe wrote: > I'm trying to respond to a javascript confirm, and so far, I have this: > > Given I intend to respond to the confirm with 'OK' > When I click the delete_payee.id link > > where the Given is defined as: > > Given /^I intend to respond to the confirm with [']([^' ]+)[']$/ do |button| > ? ?browser.add_listener(:confirm) { button == 'OK' } > end > > and the When clicks a link that is defined (in Rails) as > > link_to '[Delete]', payee_path(payee), :method => :delete, :confirm => 'Are > you sure?', :id => "delete_payee_#{payee.id}", :class => :delete_link > > But on the click of the link, I get: > > NativeException: com.gargoylesoftware.htmlunit.ScriptException: Exception > invoking jsxFunction_confirm > > Is this the correct way to do this? If not, what is? If so, how can I avoid > this error? > The code looks fine. I assume you know about Browser#confirm and that you should clean up / remove the listener if the same browser instance hits another confirm dialog later on. Can you provide a reproducible example, or at least the full backtrace of the error? From phillipkoebbe at gmail.com Sat Jan 16 15:59:49 2010 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Sat, 16 Jan 2010 14:59:49 -0600 Subject: [Celerity-users] Javascript Confirm In-Reply-To: References: <4B51F2BF.60109@gmail.com> Message-ID: <4B5228C5.6020407@gmail.com> > The code looks fine. I assume you know about Browser#confirm and that > you should clean up / remove the listener if the same browser instance > hits another confirm dialog later on. > > Can you provide a reproducible example, or at least the full backtrace > of the error? > > Hi Jari, Thanks for the response. I created a simple example, but it did not exhibit the same behavior. Funny enough, it did something else I wasn't expecting. So I have some more research to do. Peace, Phillip From peter at hexagile.com Sun Jan 17 12:35:08 2010 From: peter at hexagile.com (Peter Szinek) Date: Sun, 17 Jan 2010 18:35:08 +0100 Subject: [Celerity-users] Cookies Message-ID: Hey guys, I ran across the second site which demands cookies to be turned on (instead of getting the real page, I get an error page saying 'you need to turn cookies on blah blah'). I couldn't find how to turn cookies on - neither in the docs nor w/ google. Am I missing the obvious? (why is it not turned on initially in the first place?) Cheers, Peter From phillipkoebbe at gmail.com Sun Jan 17 16:54:05 2010 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Sun, 17 Jan 2010 15:54:05 -0600 Subject: [Celerity-users] Javascript Confirm In-Reply-To: <4B5228C5.6020407@gmail.com> References: <4B51F2BF.60109@gmail.com> <4B5228C5.6020407@gmail.com> Message-ID: <4B5386FD.9040406@gmail.com> Phillip Koebbe wrote: >> The code looks fine. I assume you know about Browser#confirm and that >> you should clean up / remove the listener if the same browser instance >> hits another confirm dialog later on. >> >> Can you provide a reproducible example, or at least the full backtrace >> of the error? > > Hi Jari, > > Thanks for the response. I created a simple example, but it did not > exhibit the same behavior. Funny enough, it did something else I > wasn't expecting. So I have some more research to do. > > Peace, > Phillip There was a small glitch in Culerity. It is fixed in 0.2.7. Peace, Phillip From jari.bakken at gmail.com Sun Jan 17 17:06:18 2010 From: jari.bakken at gmail.com (Jari Bakken) Date: Sun, 17 Jan 2010 23:06:18 +0100 Subject: [Celerity-users] Cookies In-Reply-To: References: Message-ID: On Sun, Jan 17, 2010 at 6:35 PM, Peter Szinek wrote: > Hey guys, > > I ran across the second site which demands cookies to be turned on (instead > of getting the real page, I get an error page saying 'you need to turn > cookies on blah blah'). > > I couldn't find how to turn cookies on - neither in the docs nor w/ google. > Am I missing the obvious? (why is it not turned on initially in the first > place?) > > Cheers, > Peter Cookies are turned on by default. You can inspect the cookies that have been set using Browser#cookies. Either the site is checking for cookie support in some unreliable way, or you've discovered a bug in HtmlUnit (and should report it to them). You'll have to figure out how the cookie check is done on these pages. From dorikick at gmail.com Wed Jan 27 18:08:18 2010 From: dorikick at gmail.com (doridori Jo) Date: Wed, 27 Jan 2010 15:08:18 -0800 Subject: [Celerity-users] firefox tbody problem Message-ID: <3a8841391001271508n40833c31xe0de6ec7efb0d4eb@mail.gmail.com> i noticed that firefox adds tbody after table element. does celerity by default using :firefox, has the same behavior ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jari.bakken at gmail.com Wed Jan 27 18:23:16 2010 From: jari.bakken at gmail.com (Jari Bakken) Date: Thu, 28 Jan 2010 00:23:16 +0100 Subject: [Celerity-users] firefox tbody problem In-Reply-To: <3a8841391001271508n40833c31xe0de6ec7efb0d4eb@mail.gmail.com> References: <3a8841391001271508n40833c31xe0de6ec7efb0d4eb@mail.gmail.com> Message-ID: On Thu, Jan 28, 2010 at 12:08 AM, doridori Jo wrote: > i noticed that firefox adds tbody after table element. > > does celerity by default using :firefox, has the same behavior ? > Yes. You can easily check the current DOM by doing puts browser.xml From jasoninclass at googlemail.com Thu Jan 28 13:03:04 2010 From: jasoninclass at googlemail.com (jason franklin-stokes) Date: Thu, 28 Jan 2010 19:03:04 +0100 Subject: [Celerity-users] links not being found if taged Message-ID: <30B95588-3929-4A2F-B2B0-E5E838E8E6C9@googlemail.com> dear all, using browser.links.each {|link| puts link} links like this are not found: Stellenangebote note: that the link text is wrapped in the tag under the tag any ideas how i can get this working?? p.s. the website that shows this is this: http://www.malteser-stanna.de/ four links at the top of the page in the menu Aktuelles Stellenangebote Suche Kontakt -------------- next part -------------- An HTML attachment was scrubbed... URL: From minger at gmail.com Thu Jan 28 15:35:42 2010 From: minger at gmail.com (Ming) Date: Thu, 28 Jan 2010 15:35:42 -0500 Subject: [Celerity-users] silencing INFO messages Message-ID: I'm running Celerity with proxy and proxy authenication and it keeps spitting out INFO messages like "INFO: basic authentication scheme selected Jan 28, 2010 3:26:18 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme" with each HTTP response (or request?) despite setting log_level => :off in the constructor, I keep seeing these INFO messages. How do I turn this off? TIA -------------- next part -------------- An HTML attachment was scrubbed... URL: From minger at gmail.com Thu Jan 28 16:12:25 2010 From: minger at gmail.com (Ming) Date: Thu, 28 Jan 2010 16:12:25 -0500 Subject: [Celerity-users] silencing INFO messages In-Reply-To: References: Message-ID: to follow up on my own post, the setter and constructor setter for log_level do different things. the log_level= setter does more. to silence, one has to write browser.log_level = :off i don't know if this is intended but i would expect the setter to do the same thing, inside or outside the constructor. On Thu, Jan 28, 2010 at 3:35 PM, Ming wrote: > I'm running Celerity with proxy and proxy authenication and it keeps > spitting out INFO messages like > > "INFO: basic authentication scheme selected > > Jan 28, 2010 3:26:18 PM > org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme" > > > with each HTTP response (or request?) > > despite setting > > log_level => :off > > in the constructor, I keep seeing these INFO messages. > > How do I turn this off? > > TIA > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jari.bakken at gmail.com Thu Jan 28 16:18:59 2010 From: jari.bakken at gmail.com (Jari Bakken) Date: Thu, 28 Jan 2010 22:18:59 +0100 Subject: [Celerity-users] silencing INFO messages In-Reply-To: References: Message-ID: On Thu, Jan 28, 2010 at 10:12 PM, Ming wrote: > to follow up on my own post, the setter and constructor setter for log_level > do different things. > the log_level= setter does more. to silence, one has to write > > browser.log_level = :off > > i don't know if this is intended but i would expect the setter to do the > same thing, inside or outside the constructor. > What version of Celerity are you using? The constructor calls the setter, so there shouldn't be any difference. I think what's happening is that the log level is set, then the proxy stuff is set up, which for some reason resets the log level. Then when you set it again afterwards, it's set for good. I'll try to change the order of things in the constructor. Would you be able to test if it works by checking out the code from GitHub? http://github.com/jarib/celerity From minger at gmail.com Thu Jan 28 16:51:31 2010 From: minger at gmail.com (Ming) Date: Thu, 28 Jan 2010 16:51:31 -0500 Subject: [Celerity-users] silencing INFO messages In-Reply-To: References: Message-ID: * I'm a new ruby coder, so I apologize for misunderstanding the source code. (The reader and writer accessors look different in scope, as below.) I was looking outside the constructor (and being stupid). It is true that I call browser.webclient.getCredentialsProvider.addProxyCredentials after the browser is initialized, which as you say, probably resets the info settings. I'm running Celerity gem v 0.7.8. I'd be willing to test changes from github. http://github.com/jarib/celerity/blob/master/lib/celerity/browser.rb def log_level Celerity::Util.logger_for('com.gargoylesoftware.htmlunit').level.to_s.downcase.to_sym end # # Set Java log level (default is :warning, can be any of :all, :finest, :finer, :fine, :config, :info, :warning, :severe, :off) # # @param [Symbol] level The new log level. # def log_level=(level) log_level = java.util.logging.Level.const_get(level.to_s.upcase) [ 'com.gargoylesoftware.htmlunit', 'com.gargoylesoftware.htmlunit.html', 'com.gargoylesoftware.htmlunit.javascript', 'org.apache.commons.httpclient' ].each { |package| Celerity::Util.logger_for(package).level = log_level } level end * On Thu, Jan 28, 2010 at 4:18 PM, Jari Bakken wrote: > On Thu, Jan 28, 2010 at 10:12 PM, Ming wrote: > > to follow up on my own post, the setter and constructor setter for > log_level > > do different things. > > the log_level= setter does more. to silence, one has to write > > > > browser.log_level = :off > > > > i don't know if this is intended but i would expect the setter to do the > > same thing, inside or outside the constructor. > > > > What version of Celerity are you using? > > The constructor calls the setter, so there shouldn't be any difference. > I think what's happening is that the log level is set, then the proxy > stuff is set up, which for some reason resets the log level. Then when > you set it again afterwards, it's set for good. > > I'll try to change the order of things in the constructor. Would you > be able to test if it works by checking out the code from GitHub? > > http://github.com/jarib/celerity > _______________________________________________ > Celerity-users mailing list > Celerity-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/celerity-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jari.bakken at gmail.com Thu Jan 28 18:04:49 2010 From: jari.bakken at gmail.com (Jari Bakken) Date: Fri, 29 Jan 2010 00:04:49 +0100 Subject: [Celerity-users] links not being found if taged In-Reply-To: <30B95588-3929-4A2F-B2B0-E5E838E8E6C9@googlemail.com> References: <30B95588-3929-4A2F-B2B0-E5E838E8E6C9@googlemail.com> Message-ID: HtmlUnit seems to have problems with the frames on that page. You should report this to the HtmlUnit tracker. On Thu, Jan 28, 2010 at 7:03 PM, jason franklin-stokes < jasoninclass at googlemail.com> wrote: > dear all, > > using > > browser.links.each {|link| puts link} > > links like this are not found: > > > Stellenangebote > > > note: that the link text is wrapped in the tag under the tag > > any ideas how i can get this working?? > > p.s. the website that shows this is this: http://www.malteser-stanna.de/ > four links at the top of the page in the menu > Aktuelles > Stellenangebote > Suche > Kontakt > > > > _______________________________________________ > Celerity-users mailing list > Celerity-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/celerity-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jasoninclass at googlemail.com Fri Jan 29 07:10:21 2010 From: jasoninclass at googlemail.com (jason franklin-stokes) Date: Fri, 29 Jan 2010 13:10:21 +0100 Subject: [Celerity-users] locating all text nodes in a page/frame Message-ID: dear all, i need to be able to locate all text nodes in a page/frame does anyone have any idea how i can do this? thanks for any feedback jason. From phillipkoebbe at gmail.com Sun Jan 31 06:50:01 2010 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Sun, 31 Jan 2010 05:50:01 -0600 Subject: [Celerity-users] locating all text nodes in a page/frame In-Reply-To: References: Message-ID: <4B656E69.2070503@gmail.com> jason franklin-stokes wrote: > dear all, > > i need to be able to locate all text nodes in a page/frame > does anyone have any idea how i can do this? > > thanks for any feedback > > jason. > > Hi Jason, Have you looked at http://wiki.github.com/jarib/celerity/getting-started? There are various ways to locate elements, depending on your needs. You might be most interested in the collection method that each supported type has. In this case, maybe browser.text_fields will be sufficient. I'm not sure off the top of my head what you'd have to do to isolate the elements to a specific iframe, but I'm confident it is possible and not incredibly difficult. It is probably going to have something to do with the "Finding an element inside another element" section. Hm. I haven't tried this, but I'm wondering if the element collection methods work on browser only or if you could call them on a single element. It would be great if you could find your iframe, then call text_fields on it. Give it a go. If it works, great! If not, maybe suggest that it should. :) Peace, Phillip From jasoninclass at googlemail.com Sun Jan 31 08:15:40 2010 From: jasoninclass at googlemail.com (jason franklin-stokes) Date: Sun, 31 Jan 2010 14:15:40 +0100 Subject: [Celerity-users] locating all text nodes in a page/frame In-Reply-To: <4B656E69.2070503@gmail.com> References: <4B656E69.2070503@gmail.com> Message-ID: <2D8439B2-4A63-4D75-AC9F-0D99CAF8F791@googlemail.com> hi phil, thanks for the feedback, i am actually not looking for text fields - but rather the text nodes in the dom. as text nodes do not have a tag (i.e. they are the leaf of the tag) i cannot locate them with a tag identifier - well , i could but then i would have to itterate through every conceivable tag type to get at the their text leaf which is a very big waste of resources. at the moment i am using with a helper class (see below) - which i use to render out all readable text including image alt text on the page. however this is also not very efficient as it touches every node in the dom tree. what i am really looking for is a way to collect just the text leafs in the dom tree with something like browser.text_nodes and ideas??? thanks jason. ==== HelperClass === class XpathNode attr_reader :node, :children, :parent def initialize(_dom_node, _xpath_node_parent=nil) @node = _dom_node @parent = _xpath_node_parent @children = get_children end def text_nodes all_nodes.find_all {|node| node.is_readable_text?} end def all_nodes collection = [self] collection.each {|xpath_node| xpath_node.children.each {|child| collection << child}} collection end def get_children @node.getChildren.collect {|node| XpathNode.new(node, self)} end def image? @isimage ||= @node.getNodeName.include?("img") end def text? @istext ||= @node.getNodeName.include?("text") end def text @text ||= get_text end def get_text text = @node.to_s if text? text = get_image_text if image? text end def get_image_text @image_text ||= @node.getAltAttribute end def text_container @text_container ||= get_text_container end def is_readable_text? @isreadable_text ||= text_container && !script? end def script? if text? @isscript ||= text_container.getNodeName.include?("script") end end end On Jan 31, 2010, at 12:50 PM, Phillip Koebbe wrote: > > > jason franklin-stokes wrote: >> dear all, >> >> i need to be able to locate all text nodes in a page/frame >> does anyone have any idea how i can do this? >> >> thanks for any feedback >> >> jason. >> >> > > Hi Jason, > > Have you looked at http://wiki.github.com/jarib/celerity/getting-started? There are various ways to locate elements, depending on your needs. You might be most interested in the collection method that each supported type has. In this case, maybe > > browser.text_fields > > will be sufficient. I'm not sure off the top of my head what you'd have to do to isolate the elements to a specific iframe, but I'm confident it is possible and not incredibly difficult. It is probably going to have something to do with the "Finding an element inside another element" section. Hm. I haven't tried this, but I'm wondering if the element collection methods work on browser only or if you could call them on a single element. It would be great if you could find your iframe, then call text_fields on it. Give it a go. If it works, great! If not, maybe suggest that it should. :) > > Peace, > Phillip > _______________________________________________ > Celerity-users mailing list > Celerity-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/celerity-users From jari.bakken at gmail.com Sun Jan 31 08:30:16 2010 From: jari.bakken at gmail.com (Jari Bakken) Date: Sun, 31 Jan 2010 14:30:16 +0100 Subject: [Celerity-users] locating all text nodes in a page/frame In-Reply-To: <2D8439B2-4A63-4D75-AC9F-0D99CAF8F791@googlemail.com> References: <4B656E69.2070503@gmail.com> <2D8439B2-4A63-4D75-AC9F-0D99CAF8F791@googlemail.com> Message-ID: On Sun, Jan 31, 2010 at 2:15 PM, jason franklin-stokes wrote: > > however this is also not very efficient as it touches every node in the dom tree. > > what i am really looking for is a way to collect just the text leafs in the dom tree with something like > > browser.text_nodes > > and ideas??? > There's nothing like this in Celerity's API. I'm curious how you think this could be implemented without touching every node in the DOM tree. If I needed this, I would probably start by looking at how HtmlUnit implements DomNode.getTextContent(). From jasoninclass at googlemail.com Sun Jan 31 09:07:47 2010 From: jasoninclass at googlemail.com (jason franklin-stokes) Date: Sun, 31 Jan 2010 15:07:47 +0100 Subject: [Celerity-users] locating all text nodes in a page/frame In-Reply-To: References: <4B656E69.2070503@gmail.com> <2D8439B2-4A63-4D75-AC9F-0D99CAF8F791@googlemail.com> Message-ID: <2D51A57E-BFB7-47F8-8118-E17BC7DF09E1@googlemail.com> Hi Jari, Thanks and point taken - i guess iteration is needed one way or the the other. I think that the thought behind the thought is that what I have done in my helper class already exists somewhere in celerity or htmlunit and i might be repeating code where i dont need to. I will ask the guys at htmlunit and see if they have any ideas. thanks for the feedback..... jason. On Jan 31, 2010, at 2:30 PM, Jari Bakken wrote: > On Sun, Jan 31, 2010 at 2:15 PM, jason franklin-stokes > wrote: > >> >> however this is also not very efficient as it touches every node in the dom tree. >> >> what i am really looking for is a way to collect just the text leafs in the dom tree with something like >> >> browser.text_nodes >> >> and ideas??? >> > > There's nothing like this in Celerity's API. I'm curious how you think > this could be implemented without touching every node in the DOM tree. > If I needed this, I would probably start by looking at how HtmlUnit > implements DomNode.getTextContent(). > _______________________________________________ > Celerity-users mailing list > Celerity-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/celerity-users From minger at gmail.com Sun Jan 31 16:13:01 2010 From: minger at gmail.com (Ming) Date: Sun, 31 Jan 2010 16:13:01 -0500 Subject: [Celerity-users] silencing INFO messages In-Reply-To: References: Message-ID: I tested Jari's 2010/1/28 commit and it fixes this problem. Thanks. On Thu, Jan 28, 2010 at 4:51 PM, Ming wrote: > * > > I'm a new ruby coder, so I apologize for misunderstanding the source code. (The reader and writer accessors look different in scope, as below.) I was looking outside the constructor (and being stupid). > > > It is true that I call browser.webclient.getCredentialsProvider.addProxyCredentials after the browser is initialized, which as you say, probably resets the info settings. > > I'm running Celerity gem v 0.7.8. I'd be willing to test changes from github. > > http://github.com/jarib/celerity/blob/master/lib/celerity/browser.rb > > > def log_level > Celerity::Util.logger_for('com.gargoylesoftware.htmlunit').level.to_s.downcase.to_sym > end > > > # > # Set Java log level (default is :warning, can be any of :all, :finest, :finer, :fine, :config, :info, :warning, :severe, :off) > # > # @param [Symbol] level The new log level. > # > > > def log_level=(level) > log_level = java.util.logging.Level.const_get(level.to_s.upcase) > > > [ 'com.gargoylesoftware.htmlunit', > 'com.gargoylesoftware.htmlunit.html', > 'com.gargoylesoftware.htmlunit.javascript', > 'org.apache.commons.httpclient' > ].each { |package| Celerity::Util.logger_for(package).level = log_level } > > > level > end > > * > > On Thu, Jan 28, 2010 at 4:18 PM, Jari Bakken wrote: > >> On Thu, Jan 28, 2010 at 10:12 PM, Ming wrote: >> > to follow up on my own post, the setter and constructor setter for >> log_level >> > do different things. >> > the log_level= setter does more. to silence, one has to write >> > >> > browser.log_level = :off >> > >> > i don't know if this is intended but i would expect the setter to do the >> > same thing, inside or outside the constructor. >> > >> >> What version of Celerity are you using? >> >> The constructor calls the setter, so there shouldn't be any difference. >> I think what's happening is that the log level is set, then the proxy >> stuff is set up, which for some reason resets the log level. Then when >> you set it again afterwards, it's set for good. >> >> I'll try to change the order of things in the constructor. Would you >> be able to test if it works by checking out the code from GitHub? >> >> http://github.com/jarib/celerity >> _______________________________________________ >> Celerity-users mailing list >> Celerity-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/celerity-users >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dorikick at gmail.com Sun Jan 31 17:11:53 2010 From: dorikick at gmail.com (doridori Jo) Date: Sun, 31 Jan 2010 14:11:53 -0800 Subject: [Celerity-users] locating all text nodes in a page/frame In-Reply-To: <2D51A57E-BFB7-47F8-8118-E17BC7DF09E1@googlemail.com> References: <4B656E69.2070503@gmail.com> <2D8439B2-4A63-4D75-AC9F-0D99CAF8F791@googlemail.com> <2D51A57E-BFB7-47F8-8118-E17BC7DF09E1@googlemail.com> Message-ID: <3a8841391001311411i4221347fmef08aeeda88ae096@mail.gmail.com> is it possible to do browser.iframe.text On Sun, Jan 31, 2010 at 6:07 AM, jason franklin-stokes < jasoninclass at googlemail.com> wrote: > Hi Jari, > > Thanks and point taken - i guess iteration is needed one way or the the > other. > > I think that the thought behind the thought is that what I have done in my > helper class already exists somewhere in celerity or htmlunit and i might be > repeating code where i dont need to. > > I will ask the guys at htmlunit and see if they have any ideas. > > thanks for the feedback..... > > jason. > > On Jan 31, 2010, at 2:30 PM, Jari Bakken wrote: > > > On Sun, Jan 31, 2010 at 2:15 PM, jason franklin-stokes > > wrote: > > > >> > >> however this is also not very efficient as it touches every node in the > dom tree. > >> > >> what i am really looking for is a way to collect just the text leafs in > the dom tree with something like > >> > >> browser.text_nodes > >> > >> and ideas??? > >> > > > > There's nothing like this in Celerity's API. I'm curious how you think > > this could be implemented without touching every node in the DOM tree. > > If I needed this, I would probably start by looking at how HtmlUnit > > implements DomNode.getTextContent(). > > _______________________________________________ > > Celerity-users mailing list > > Celerity-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/celerity-users > > _______________________________________________ > Celerity-users mailing list > Celerity-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/celerity-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: