!!

Welcome to Selenium Webdriver Forum

As a web user you can read and search through forum content. Once you have registered and signed you can post topics, post replies, set up watch lists, modify forum settings, and use private messaging.

Author Topic: visual studio error handling issue  (Read 626 times)

Michael

  • Web User
visual studio error handling issue
« on: February 23, 2012, 08:53:25 PM »
Hi  - I am playing around with a program with which I use Selenium
 Webdriver's c# binaries.  I am using the following setup:  Win7 64
 bit, Visual Studio 2010. My program is written using Vb, and I use the
 webdriver c# binaries to interact with Firefox.  I am not using Nunit
 or a testing framework.
 here's the problem.  I am testing interacting with Google as per the
 example in the documentation.  if for some reason i switch the website
 in the browser and then run the same code, then obviously since there
 is no element named 'q', it causes an error.  However, it doesn't seem
 to throw a catchable error even though i put a try/catch around it.
 
Is there a way for me to catch this or other errors within my VB
 code?  The problem is that it seems like it brings my app to a
 grinding halt - it cannot recover from this.
 
Any help appreciated in advance.
 
Michael

Nathan Dace

  • Web User
Re: visual studio error handling issue
« Reply #1 on: February 23, 2012, 08:53:40 PM »
Ensure that you exception catching is wrapped around your Find
 method.
 Could you reply with a code sample where the exception is not being
 caught?  It may be easier to assist that way.
 
On Nov 4, 9:19 pm, Michael <goll...@gmail.com> wrote:
 

- Show quoted text -

Michael

  • Web User
Re: visual studio error handling issue
« Reply #2 on: February 23, 2012, 08:53:50 PM »
Nathan,
 Thank you for your reply.  Below is the chunk of relevant code.  The
 subroutine testSelenium2 is executed first by pressing a button on the
 form.  Then the subroutine testSelenium3 is executed by pressing a
 different button on the form.
 
Thanks,
 Michael
 
Imports OpenQA.Selenium.IE
 Imports OpenQA.Selenium.Chrome
 Imports OpenQA.Selenium.Firefox
 Imports OpenQA.Selenium
 
Friend Class Mouse
 Inherits System.Windows.Forms.Form
 
    Public x As IWebDriver
     Public iQuery As IWebElement
 
    Private Sub testSelenium2()
         x = New FirefoxDriver
         x.Navigate().GoToUrl("http://www.google.com/")
         iQuery = x.FindElement(By.Name("q"))
         iquery.SendKeys("Cheese")
         iquery.SendKeys(Keys.Enter)
     End Sub
 
    Private Sub testSelenium3()        Try            iQuery =
 x.FindElement(By.Name("q"))            iQuery.SendKeys("Cheese" &
 Keys.Enter)        Catch ex As Exception            MsgBox("error")   
     End Try    End Sub
 
End Class
 
On Nov 6, 12:46 am, Nathan Dace <nathand...@gmail.com> wrote:
 

- Show quoted text -

Selenium Webdriver

Re: visual studio error handling issue
« Reply #2 on: February 23, 2012, 08:53:50 PM »

Michael

  • Web User
Re: visual studio error handling issue
« Reply #3 on: February 23, 2012, 08:54:01 PM »
Here is some additional information about the error it generates in VS
 2010 (VB).  It seems like it is trying to find the source code for the
 C# Dlls to debug through?  All I downloaded though was the window
 binaries.  I am running my project in debug mode.  Do I need to
 download the source code to go any further?  I just want to catch the
 error.  I know what's causing the error - trying to find an element
 that doesn't exist on the page - but I just care about catching the
 error so I know that error occurred and allowing the vb program to
 continue without failing or freezing.  Error information below.
 Thanks,
 Michael
 
No Source Available
 There is no source code available for the current location
 
To investigate further, try one of these options:
 Browse to find Source
 
Call stack location:
 WebDriver.dll!OpenQA.Selenium.By.Name(string nameToFind) Line 137
 
Source file information:
 Locating source for 'c:\Projects\WebDriver\trunk\dotnet\src\WebDriver
 \By.cs'. Checksum: MD5 {94 23 40 bd e6 b8 48 2a 9 18 54 d9 c2 83 a3
 db}
 The file 'c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\By.cs' does
 not exist.
 Looking in script documents for 'c:\Projects\WebDriver\trunk\dotnet\src
 \WebDriver\By.cs'...
 Looking in the projects for 'c:\Projects\WebDriver\trunk\dotnet\src
 \WebDriver\By.cs'.
 The file was not found in a project.
 Looking in directory 'c:\Program Files\Microsoft Visual Studio 9.0\VC
 \crt\src\'...
 Looking in directory 'c:\Program Files\Microsoft Visual Studio 9.0\VC
 \atlmfc\src\mfc\'...
 Looking in directory 'c:\Program Files\Microsoft Visual Studio 9.0\VC
 \atlmfc\src\atl\'...
 Looking in directory 'c:\Program Files\Microsoft Visual Studio 9.0\VC
 \atlmfc\include\'...
 Looking in directory 'E:\'...
 The debug source files settings for the active solution indicate that
 the debugger will not ask the user to find the file: c:\Projects
 \WebDriver\trunk\dotnet\src\WebDriver\By.cs.
 The debugger could not locate the source file 'c:\Projects\WebDriver
 \trunk\dotnet\src\WebDriver\By.cs'.
 
On Nov 6, 9:38 pm, Michael <goll...@gmail.com> wrote:
 

- Show quoted text -

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
339 Views
Last post February 21, 2012, 08:34:48 PM
by Wesley Chen
24 Replies
1652 Views
Last post February 23, 2012, 07:08:59 PM
by Thiago Morais
1 Replies
651 Views
Last post April 02, 2012, 09:31:29 PM
by Jason Leyba
1 Replies
700 Views
Last post May 03, 2012, 05:54:00 PM
by Krishnan Mahadevan
0 Replies
1411 Views
Last post June 19, 2012, 04:20:44 PM
by SeleniumWebdriver Admin
2 Replies
809 Views
Last post June 25, 2012, 12:09:58 AM
by nhatekar
1 Replies
394 Views
Last post July 24, 2012, 05:57:07 PM
by rolandormrod82

Review www.seleniumwebdriver.com on alexa.com