SivajiRaw
SivajiRaw

Reputation: 43

c# - geckodriver.exe selenium 3.8 not running nunit 3.9

I try to run Nunit_selenium automation in updated firefox version,

vs 13,
selenium webdriver 3.8.0
NUnit3TestAdapter.3.9.0
Selenium.Support.3.8.0
Selenium.WebDriverBackedSelenium.3.8.0

Firefox launched but driver url link not updated

issue :in firefox notrun_image

please find the below code : . . . . . . . /

namespace SanityTesting
{

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using NUnit.Framework.Constraints;
    using NUnit.Framework;
    using NUnit.Core.Extensions;
    using System.Configuration;
    using System.IO;
    using System.Reflection;
    using OpenQA.Selenium.Interactions;
    using OpenQA.Selenium;
    using Syncfusion.UnitTesting.Framework;
    using OpenQA.Selenium.Remote;
    using System.Threading;
    using OpenQA.Selenium.Support.UI;
    using System.Collections;
    using OpenQA.Selenium.Firefox;
    using System.Diagnostics;
    using System.Globalization;
    using System.Drawing;
    using SanityTesting.AccordionFluent;
    using System.Windows.Forms;

    [TestFixture("Firefox")]
    [TestDirectory("..\\..\\Accordion\\")]
    public class EmberJS_Accordion : NUnitUtil
    {
        string activeBrowser;

        public EmberJS_Accordion(string browser)
        {

            FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"C:\Drivers");
            service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";          
            System.Environment.SetEnvironmentVariable("webdriver.gecko.driver", "C:\\Drivers\\geckodriver.exe");
            FirefoxDriver driver = new FirefoxDriver(service); //    FirefoxDriver driver = new FirefoxDriver(); 
            //driver = GetWebDriverForBrowser(browser);    
            //FirefoxProfile profile = new FirefoxProfile();
            //profile.SetPreference("browser.startup.page", 0); // Empty start page
            //profile.SetPreference("browser.startup.homepage_override.mstone", "ignore"); // Suppress the "What's new" page

           // return new FirefoxDriver(profile);
            activeBrowser = browser;           
        }

        [TestFixtureTearDown]
        public void quitDriver()
        {
            driver.Quit();
        }

        public void TakeAndCompareScreenshotByLocator(By Locator, string fileName)
        {
            IWebElement contents = driver.FindElementAfterClickable(Locator);
            TakeAndCompareScreenshot(contents, fileName);
        }




        [Test, TestCaseSource(typeof(AccordionModel), "Sanity_Accordion")]
        [Category("Sanity")]
        [Component(Component.Accordion)]
        public void EmberJS_Accordion_Sanity(string url, int time)
        {

            AutomationHelpers.GotoPage(driver, url);
            driver.Navigate().Refresh();
            driver.WaitForElementClickable(By.CssSelector(".e-acrdn"), time);

            Thread.Sleep(200);
            IWebElement contents = driver.FindElement(By.ClassName("cols-sample-area"));
            TakeAndCompareScreenshot(contents);



        }
}

Upvotes: 0

Views: 260

Answers (1)

Murthi
Murthi

Reputation: 5347

change the following line of code,

FirefoxDriver driver = new FirefoxDriver(service);

to

driver = new FirefoxDriver(service);

I have doubt, is your NUnitUtil class have driver member variable. if yes, then above code may work.

Upvotes: 1

Related Questions