Hi Everyone, As you all suggested here is a small snippet

use strict; use warnings FATAL => 'all'; use Selenium::Remote::Driver; use Selenium::Chrome; use Selenium::Remote::WebElement; my $driver = Selenium::Chrome->new(binary=>"D:\\chromedriver_win32\\ch +romedriver.exe"); $driver->maximize_window(); $driver->set_implicit_wait_timeout(1000); $driver->get('http://google.com'); $driver->pause(2000); $driver->find_element_by_xpath(".//*[\@id='lst-ib']")->send_keys('perl +monks'); $driver->pause(5000); print "1"; #The below line is just for testing that what happens if element is no +t present.And it even gives no warning or anything. $driver->find_element_by_xpath("abc"); $driver->pause(5000); print "2"; #The below line is just for testing that what happens if element is no +t present. This gives a warning as stated in below para. $driver->find_element_by_xpath("def")->click; $driver->pause(5000); $driver->find_element_by_xpath(".//*[\@id='sblsbb']/button")->click; $driver->pause(5000); $driver->shutdown_binary;

So in the above snippet which is for searching something in Google. The lines $driver->find_element_by_xpath("abc"); and $driver->find_element_by_xpath("def")->click; are just added to check what happens for elements not present.
The command prompt shows the error Use of uninitialized value in substitution iterator at C:/Perl/site/lib/Selenium/Remote/Commands.pm line 437.. That too is only for the one on which click is also defined. How can I catch these to call another sub for sending notification mails. Also please let me know how can I catch error for the line with no click element as it is not even giving any warning in the Prompt.
One more thing the Output for above throws the warning first then 1 and 2. Is it always that warnings are thrown first not depending on the line by line execution.


In reply to Re^5: Error Handling in Selenium by 9mohit2
in thread Error Handling in Selenium by 9mohit2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.