3

Amended Code For Launching Browser In VS 2015[Screen Shot Of Error List - 02][1].

@alecxe - I have edited the code. But, I still get errors. Thanks very much for your help.

=========================================================================

I have done this several times before and it has worked. But for some reason, it is not working. I am using Microsoft Visual Studio 2015 (Community Edition - if that Screen Shot Of Error List -03 helps. I have downloaded the necessary libraries and added the required dependencies in MS/Visual Studio. I have also added a picture of the error list.

Here is the code:

using OpenQA.Selenium.Firefox;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using System.Threading.Tasks;


namespace CV_Library_P.OM_09_2017
{
    class Valid_Username_Valid_Password
    {

        //Instantiate Firefox Driver
        var driver = new FirefoxDriver();

        FirefoxDriver.Navigate().GoToUrl("https://www.cv-library.co.uk/candidate/login");

        //Enter User Name - Email Address
        var user = driver.FindElement(By.Id("cand-login-left"));
        user.SendKeys("[email protected]");

            //Enter Password - Account Pasword
            var pass = driver.FindElement(By.Id("cand-login-left"));
        pass.SendKeys("p@55word123!");

            //Click on Login button
            driver.FindElement(By.Id("cand-login-left")).Click();

Error List From Launching Browser And Going To Website

1
  • I installed MS/Visual Studio 2015 on another PC, and, I was able to do a successful build of the code. But, I got the error message: openqa.selenium.webdriverexception ​ {"unable to find a matching set of capabilities"}​​ My google search of the error indicates that it is likely a compatibility issue between Selenium Webdriver and Firefox. I will try and trouble shoot by running Chrome Driver instead. Thanks.
    – OA345
    Commented Sep 17, 2017 at 19:37

1 Answer 1

3

1: Your first error says that: Invalid token class/interface/member declaration
Ans: You have missed basic concept of Encapsulation

  • You have not declared the main method.
  • Every code should be capsulated within the: Class--> Method-->Data

2: Error Method should have a return type.
This error occurs because you have not declared any method within your class.

3: If you are using Selenium 3.0 or greater version then you must have to initialize Firefox-Geckodriver path in your code. Check here, if don't know how to do this.

4: Instead of FirefoxDriver.Navigate().GoToUrl("") use:

driver.get("Your AppURL")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.