`block in <main>': uninitialized constant By (NameError)

53 views
Skip to first unread message

Ma St

unread,
Dec 24, 2014, 11:47:28 AM12/24/14
to public-...@googlegroups.com
I am attempting to locate a text value of "Welcome" on a web page and assert if it exists or not.  I think I identified the elements, but when it gets to this line, it fails.  It does not recognize the "By" keyword.  Do I need a Require statement for XPath?
 
This is the HTML:

<tbody>

<tr>

<td align="left">

<div class="section-title-holder" id="section-title-holder">

<span id="lblTitleHolder">Welcome</span>

</div>

</td>

 

This is my Ruby file line to locate the Welcome id.
wait.until { browser.find_element(By.xpath("//div[contains(@class='section')and text='Welcome']")).displayed? puts "Test Passed: The welcome exists"}
 
 
Error:
test2.rb:42:in `block in <main>': uninitialized constant By (NameError)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/w
ebdriver/common/wait.rb:39:in `until'
        from test2.rb:42:in `<main>'
Reply all
Reply to author
Forward
0 new messages