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.0000 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="add">Add 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.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.