Hi,

You could also do the following:

browser.link(:id, "showlink").when_present.click

Joe


On Fri, Jan 3, 2014 at 9:28 AM, Joe Fleck <[email protected]> wrote:

> The 5 represents the time in which it will wait.  I believe its 5 seconds.
>  You could also use the 'wait_until_present' method.
>
>
> http://rdoc.info/gems/watir-webdriver/Watir/EventuallyPresent#wait_until_present-instance_method
>
> browser.link(:id, "showlink").wait_until_present
> browser.link(:id, "showlink").click
>
> This waits 30 seconds before failing and if the object is present during
> that 30 seconds it moves on to the next line.  Another plus is it looks
> cleaner.
>
> Joe
>
>
> On Fri, Jan 3, 2014 at 7:53 AM, Ayushman Choudhary <
> [email protected]> wrote:
>
>> the sleep(5) works but what is the significance of 5 here? do we use
>> value less than this ??
>>
>>
>> On Friday, September 2, 2011 2:05:28 PM UTC+5:30, Amit Bobade wrote:
>>>
>>> Hi Micheal,
>>>
>>> I tried to access element as follows. Such issues occur with my scripts
>>> sometimes. Such problems really suck when I give demo to my senior.
>>>
>>> Am I using Watir in wrong direction?
>>> Is it because of slow connection?
>>>
>>> *RUBY CODE: *
>>>
>>>      browser = Watir::Browser.new :ff
>>>     browser.goto("http://yogita/gosocially/re-login.php";)
>>>     browser.form(:id, "signin").text_field(:id,
>>> "username").set("earthmplex")
>>>     browser.form(:id, "signin").text_field(:id,
>>> "password").set("earth123")
>>>     browser.form(:id, "signin").button(:value, "Sign In").click
>>>     sleep(5) #After adding this line, there was no error.
>>>     browser.link(:id, "showlink").click
>>>
>>>
>>> *HTML CODE: *
>>>
>>> <div class="attch-img">
>>>
>>>
>>>     <a href="javascript:void(0);" class="attach_link dashboard_sprites OFF" 
>>> id="showlink" title="Link"></a>
>>>
>>>
>>>  </div>
>>>
>>>
>>> Thanks,
>>> Amit.
>>>
>>>
>>> On Thu, Sep 1, 2011 at 8:26 AM, Michael <[email protected]> wrote:
>>>
>>>> Please post your ruby code as well so we can see how you are trying to
>>>> locate this element. You can always use wait_until { … locate link … }, but
>>>> if this is truly static HTML I would be surprised if that was necessary.
>>>>
>>>> On 2011-08-31, at 12:32 AM, Amit Bobade wrote:
>>>>
>>>> Thanks for your prompt reply, Micheal.
>>>>
>>>> Element is not hidden. It is very simple HTML code. I tried using
>>>> sleep( ) method for this and fortunately it worked !!!!
>>>>
>>>> I don't know the exact problem and this may not be a proper solution.
>>>> Could you please suggest something more productive?
>>>>
>>>> HTML CODE:
>>>>
>>>> <div class="attch-img">
>>>>
>>>>     <a href="javascript:void(0);" class="attach_link dashboard_sprites 
>>>> OFF" id="showlink" title="Link"></a>
>>>>
>>>>
>>>>
>>>>  </div>
>>>>  <div class="attch-img">
>>>>
>>>>      <a href="javascript:void(0);" style="opacity: 0.5;" class="OFF 
>>>> attach_video dashboard_sprites" title="Configure Youtube to upload 
>>>> video"></a>
>>>>
>>>>
>>>>  </div>
>>>>
>>>>
>>>> Thanks,
>>>> -Amit
>>>>
>>>> On Wed, Aug 31, 2011 at 11:51 AM, Michael <[email protected]> wrote:
>>>>
>>>>> Your HTML and code snippets would help us see what is going on.
>>>>>
>>>>> In general you cannot interact with elements that are hidden (not
>>>>> visible). This may be occurring for a few reasons:
>>>>> - element is hidden (or positioned off the screen) by CSS styles or
>>>>> JavaScript
>>>>> - your selector found a different element matching your selector, and
>>>>> this element is hidden
>>>>>
>>>>> On 2011-08-31, at 12:06 AM, Amit Bobade wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>>
>>>>> I am getting following error while running my script on FF.
>>>>>
>>>>> `WebDriverError': Element is not currently visible and so may not be
>>>>> interacted with (Selenium::WebDriver::Error::ElementNotDisplayedError)
>>>>>
>>>>> I am using Ruby187 and Watir-webdriver.
>>>>>
>>>>> Could someone tell me why this error is occuring?
>>>>>
>>>>> --
>>>>> Thanks and Regards,
>>>>> Amit
>>>>>
>>>>>
>>>>> --
>>>>> 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]
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> 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]
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Thanks and Regards,
>>>> Amit
>>>>
>>>>
>>>> --
>>>> 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]
>>>>
>>>>
>>>>  --
>>>> 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]
>>>>
>>>
>>>
>>>
>>> --
>>> Thanks and Regards,
>>> Amit
>>>
>>>  --
>> --
>> 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/groups/opt_out.
>>
>
>

-- 
-- 
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/groups/opt_out.

Reply via email to