[wtr-general] Re: Ruby Watir to get specific html element of a page

2015-02-23 Thread Super Kevy
What exactly are you trying to do?
Get the value of the street (i.e return the street address of the user?)

I assume you are using watir-webdriver ruby.  Correct?



On Friday, February 20, 2015 at 3:20:36 AM UTC-6, Nice Faith wrote:

 i try this one:

  puts @browser.execute_script -JS
 var link = document.getElementById('street')
 return link.innerHTML
 JS

 .. there's no error but then there's no display...

 On Tuesday, February 17, 2015 at 2:31:04 PM UTC+8, Nice Faith wrote:

 Hai Guys. I am just trying to explore or learn Watir.
 I have already try this one:

 puts browser.text
 and it works. I would like to ask if it is possible to display or print 
 only the specific element or html tags.
 For example this one:

 button class=btn btn-add data-role=addAdd New User/button
 Is there any way to get this element only? Not the whole Page source.



-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Ruby Watir to get specific html element of a page

2015-02-20 Thread Chuck van der Linden
On Tuesday, February 17, 2015 at 5:51:17 PM UTC-8, Nice Faith wrote:

 I have this line of codes:

 if @browser.text_field(:id = street).exists?
   puts street exist
   puts @browser.text_field(:id = street).html
 else
   puts street does not exist
 end

 and the result is:

 Run options: 

 # Running tests:






 street exist
 E

 Finished tests in 83.598781s, 0.0120 tests/s, 0. assertions/s.

   1) Error:
 test_login(TC_Login):
 Selenium::WebDriver::Error::JavascriptError: invalid 'in' operand a
 [remote server] http://sample.org/user/ line 68  Function:18:in `G'
 [remote server] http://sample.org/user/ line 68  Function:18:in 
 `anonymous//'
 [remote server] http://sample.org/user/ line 68  Function:15:in 
 `anonymous/'
 [remote server] http://sample.org/user/ line 68  Function:15:in 
 `anonymous'
 [remote server] http://sample.org/user/:68:in `handleEvaluateEvent'
 
 c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/response.rb:52:in
  
 `assert_ok'
 
 c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/response.rb:15:in
  
 `initialize'
 
 c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/common.rb:59:in
  
 `new'
 
 c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/common.rb:59:in
  
 `create_response'
 
 c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/default.rb:66:in
  
 `request'
 
 c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/common.rb:40:in
  
 `call'
 
 c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/bridge.rb:640:in
  
 `raw_execute'
 
 c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/bridge.rb:618:in
  
 `execute'
 
 c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/bridge.rb:339:in
  
 `executeScript'
 
 c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/common/driver.rb:193:in
  
 `execute_script'
 
 c:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.11/lib/watir-webdriver/atoms.rb:20:in
  
 `execute_atom'
 
 c:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:290:in
  
 `outer_html'
 excel.rb:277:in `test_login'

 1 tests, 0 assertions, 0 failures, 1 errors, 0 skips

 It diplays street exist...so the problem there is on displaying the html.



1) are you sure there is any actual HTML code (tags etc) contained by the 
text field object?   Do you maybe just want to use .text instead of .html?  

2) your error is on line 277 of excel.rb ,.,  what is on that line?  

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Ruby Watir to get specific html element of a page

2015-02-20 Thread Nice Faith
i try this one:

 puts @browser.execute_script -JS
var link = document.getElementById('street')
return link.innerHTML
JS

.. there's no error but then there's no display...

On Tuesday, February 17, 2015 at 2:31:04 PM UTC+8, Nice Faith wrote:

 Hai Guys. I am just trying to explore or learn Watir.
 I have already try this one:

 puts browser.text
 and it works. I would like to ask if it is possible to display or print 
 only the specific element or html tags.
 For example this one:

 button class=btn btn-add data-role=addAdd New User/button
 Is there any way to get this element only? Not the whole Page source.



-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Ruby Watir to get specific html element of a page

2015-02-20 Thread Nice Faith
The code in the line 277 is puts @browser.text_field(:id = street).html. 
I try this code:

 puts @browser.execute_script('return 
document.getElementById(street)[0]').html

but the error says:
Error: test_login(TC_Login)
: NoMethodError: undefined method `html' for nil:NilClass
excel.rb:275:in `test_login'

and I also try this one:
puts @browser.execute_script('return 
document.getElementById(street)[0]').innerHTML

and the error was:

Error: test_login(TC_Login)
: NoMethodError: undefined method `innerHTML' for nil:NilClass
excel.rb:275:in `test_login'

but if I use puts @browser.execute_script('return 
document.getElementsByClassName(sample_class)[0]').html

it works.. it display the html tags...


On Tuesday, February 17, 2015 at 2:31:04 PM UTC+8, Nice Faith wrote:

 Hai Guys. I am just trying to explore or learn Watir.
 I have already try this one:

 puts browser.text
 and it works. I would like to ask if it is possible to display or print 
 only the specific element or html tags.
 For example this one:

 button class=btn btn-add data-role=addAdd New User/button
 Is there any way to get this element only? Not the whole Page source.



-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Ruby Watir to get specific html element of a page

2015-02-17 Thread Nice Faith
I have this line of codes:

if @browser.text_field(:id = street).exists?
  puts street exist
  puts @browser.text_field(:id = street).html
else
  puts street does not exist
end

and the result is:

Run options: 

# Running tests:






street exist
E

Finished tests in 83.598781s, 0.0120 tests/s, 0. assertions/s.

  1) Error:
test_login(TC_Login):
Selenium::WebDriver::Error::JavascriptError: invalid 'in' operand a
[remote server] http://sample.org/user/ line 68  Function:18:in `G'
[remote server] http://sample.org/user/ line 68  Function:18:in 
`anonymous//'
[remote server] http://sample.org/user/ line 68  Function:15:in 
`anonymous/'
[remote server] http://sample.org/user/ line 68  Function:15:in 
`anonymous'
[remote server] http://sample.org/user/:68:in `handleEvaluateEvent'

c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/response.rb:52:in
 
`assert_ok'

c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/response.rb:15:in
 
`initialize'

c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/common.rb:59:in
 
`new'

c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/common.rb:59:in
 
`create_response'

c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/default.rb:66:in
 
`request'

c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/common.rb:40:in
 
`call'

c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/bridge.rb:640:in
 
`raw_execute'

c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/bridge.rb:618:in
 
`execute'

c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/bridge.rb:339:in
 
`executeScript'

c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/common/driver.rb:193:in
 
`execute_script'

c:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.11/lib/watir-webdriver/atoms.rb:20:in
 
`execute_atom'

c:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:290:in
 
`outer_html'
excel.rb:277:in `test_login'

1 tests, 0 assertions, 0 failures, 1 errors, 0 skips

It diplays street exist...so the problem there is on displaying the html.


On Tuesday, February 17, 2015 at 2:31:04 PM UTC+8, Nice Faith wrote:

 Hai Guys. I am just trying to explore or learn Watir.
 I have already try this one:

 puts browser.text
 and it works. I would like to ask if it is possible to display or print 
 only the specific element or html tags.
 For example this one:

 button class=btn btn-add data-role=addAdd New User/button
 Is there any way to get this element only? Not the whole Page source.



-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Ruby Watir to get specific html element of a page

2015-02-17 Thread Chuck van der Linden
On Tuesday, February 17, 2015 at 1:32:36 AM UTC-8, Nice Faith wrote:

 Ahmf. the web element is present..But when I try to print/put it it 
 doesn't work.


can you provide us with the URL to the page you are working with?

what does 'it doesn't work' mean?  did you get an error, 

Can you show us the code you tried to run, or if using IRB copy what you 
typed and what responses you got. 

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [wtr-general] Re: Ruby Watir to get specific html element of a page

2015-02-17 Thread Velraj Prabhu
To check whether the button present in this page, you can use like this

browser.button(:class = btn btn-add , :text = Add New User).exists?

it would return true if web element is present.


-- 
Regards,
Velurajprabhu.B

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Ruby Watir to get specific html element of a page

2015-02-17 Thread Nice Faith
Ahmf. the web element is present..But when I try to print/put it it 
doesn't work.

On Tuesday, February 17, 2015 at 2:31:04 PM UTC+8, Nice Faith wrote:

 Hai Guys. I am just trying to explore or learn Watir.
 I have already try this one:

 puts browser.text
 and it works. I would like to ask if it is possible to display or print 
 only the specific element or html tags.
 For example this one:

 button class=btn btn-add data-role=addAdd New User/button
 Is there any way to get this element only? Not the whole Page source.



-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Ruby Watir to get specific html element of a page

2015-02-16 Thread Chuck van der Linden
On Monday, February 16, 2015 at 10:31:04 PM UTC-8, Nice Faith wrote:

 Hai Guys. I am just trying to explore or learn Watir.
 I have already try this one:

 puts browser.text
 and it works. I would like to ask if it is possible to display or print 
 only the specific element or html tags.
 For example this one:

 button class=btn btn-add data-role=addAdd New User/button
 Is there any way to get this element only? Not the whole Page source.


puts browser.button(:data_role = 'add').text

or

puts browser.button(:class = 'btn btn-add').text 

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[wtr-general] Re: Ruby Watir to get specific html element of a page

2015-02-16 Thread Nice Faith
Ahmm. Iately, I try what you have suggested. But then, it doesn't work. 
There's no error but it was not displayed

On Tuesday, February 17, 2015 at 2:31:04 PM UTC+8, Nice Faith wrote:

 Hai Guys. I am just trying to explore or learn Watir.
 I have already try this one:

 puts browser.text
 and it works. I would like to ask if it is possible to display or print 
 only the specific element or html tags.
 For example this one:

 button class=btn btn-add data-role=addAdd New User/button
 Is there any way to get this element only? Not the whole Page source.



-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.