Try deleting the sleep and changing: browser.link(:id, "showlink").click to browser.link(:id, "showlink").when_present.click
Does that fix it 100% of the time? It kind of sounds like you have some sort of panel that's loading a bunch of stuff up before making itself visible. Brett On Fri, Sep 2, 2011 at 4:35 AM, Amit Bobade <[email protected]> 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] > -- 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]
