I have implemented alannings example from the below link: , however, as each test runs, they all come back with GoogleTest as there name.I would like ot be able to get each result append with the browser it ran in. What would be the best approach
Run Selenium tests in multiple browsers one after another from C# NUnit
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Chrome;
using System.Threading;
using NUnit.Framework;
using OpenQA.Selenium.Support.UI;
namespace UnitTestProject1
{
[TestFixture(typeof(FirefoxDriver))]
[TestFixture(typeof(InternetExplorerDriver))]
[TestFixture(typeof(ChromeDriver))]
public class agentLogin<TWebDriver> where TWebDriver : IWebDriver, new()
{
private IWebDriver driver;
[SetUp]
public void CreateDriver () {
this.driver = new TWebDriver();
}
[Test]
public void agentLogin_Smoke() {
driver.Url = "http://dev.URL.com/Login/Index.aspx";
Assert.IsTrue(driver.FindElement(By.Id("lblHeader")).Displayed);
//Agent Login name
var agentLogin = driver.FindElement(By.Id("tbLoginName"));
agentLogin.Clear();
agentLogin.SendKeys("userID");
Related
I am trying to write a simple c# program to just connect to my Solr instance. I have downloaded the SolrNet library and made reference to SolrNet.dll in my project. I am following some of the examples online but have been getting the error "ServiceLocationProvider must be set" when the last line of my code is executed. Following is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using CommonServiceLocator;
using SolrNet;
using SolrNet.Attributes;
using SolrNet.Impl;
using SolrNet.Impl.DocumentPropertyVisitors;
using SolrNet.Impl.FacetQuerySerializers;
using SolrNet.Impl.FieldParsers;
using SolrNet.Impl.FieldSerializers;
using SolrNet.Impl.QuerySerializers;
using SolrNet.Impl.ResponseParsers;
using SolrNet.Mapping;
using SolrNet.Mapping.Validation;
using SolrNet.Mapping.Validation.Rules;
using SolrNet.Schema;
using SolrNet.Utils;
namespace WebApplication1
{
public class Post
{
[SolrField("id")]
public string id { get; set; }
}
public class Program
{
public static void Main(string[] args)
{
var connection = new SolrConnection("http://localhost:8983/solr/test");
Startup.Init<Post>(connection.ServerURL);
var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Post>>();
}
}
}
Can someone tell me what am I missing?
Thank You
I'm beginner in Xamarin Test Cloud and I want to write tests for Xamarin Test Cloud.
I have Xamarin UITests in my solution and I tried to launch REPL, but UITest REPL window didn't open.
using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
using Xamarin.UITest;
using Xamarin.UITest.Android;
using Xamarin.UITest.Queries;
namespace MurakamiKiev.UITests
{
[TestFixture]
public class Tests
{
AndroidApp app;
[SetUp]
public void BeforeEachTest ()
{
app = ConfigureApp.Android.StartApp ();
}
[Test]
public void TestLaunch ()
{
app.Repl();
}
}
}
Where is the error?
Also, what I need to write to launch specified activity?
If you don't have the application source code in the same solution then you'll need to specify the prebuilt app by pointing to it via a full path.
[SetUp]
public void BeforeEachTest ()
{
app = ConfigureApp.Android.ApkFile("<path-as-string>").StartApp ();
}
I am trying below code with AppiumDriver but getting error. I am using beloe code and using appium.dotnet driver version 1.5.1.1
using NUnit.Framework;
using System;
using System;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Appium.Interfaces;
using OpenQA.Selenium.Appium.MultiTouch;
using OpenQA.Selenium.Interactions;
namespace TestAutomation_AppiumFramework
{
[TestFixture()]
public class TestAppium
{
private AppiumDriver<AppiumWebElement> driver;
private static Uri testServerAddress = new Uri("http:127.0.01:4723/wd/hub"); // If Appium is running locally
private static TimeSpan INIT_TIMEOUT_SEC = TimeSpan.FromSeconds(180); /* Change this to a more reasonable value */
private static TimeSpan IMPLICIT_TIMEOUT_SEC = TimeSpan.FromSeconds(10); /* Change this to a more reasonable value */
[TestInitialize]
public void BeforeAll()
{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("device", "Android");
capabilities.SetCapability(CapabilityType.Platform, "Windows");
capabilities.SetCapability("deviceName", "H30-U10");
capabilities.SetCapability("platformName", "Android");
capabilities.SetCapability("platformVersion", "4.3");
capabilities.SetCapability("appPackage", "com.android.calculator2");
capabilities.SetCapability("appActivity", "com.android.calculator2.Calculator");
driver = new AppiumDriver(testServerAddress,capabilities, INIT_TIMEOUT_SEC);
driver.Manage().Timeouts().ImplicitlyWait(IMPLICIT_TIMEOUT_SEC);
}
Getting error -on this line -
driver = new AppiumDriver(testServerAddress,capabilities, INIT_TIMEOUT_SEC);
Saying Using the generic type 'OpenQA.Selenium.Appium.AppiumDriver' requires 1 type arguments]
AppiumDriver is an Abstract class. You have to initialize one of the concrete classes such as AndroidDriver or IOSDriver and define the argument type associated with it.
I created new unit test project and and trying to test some links with selenium webdriver, but I am getting this error. When I change output type to console or windows, I get 'Program does not contain a static 'Main' method suitable for an entry point'. Please help me fix this
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
using System.Collections.Generic;
using OpenQA.Selenium.Support.PageObjects;
namespace billingtest
{
[TestClass]
public class test
{
FirefoxDriver driver;
[TestInitialize()]
public void SyncDriver()
{
driver = new FirefoxDriver();
driver.Manage().Window.Maximize();
}
[TestMethod]
public void LoginToBilling()
{
driver.Navigate().GoToUrl("http://localhost:57862");
driver.FindElement(By.Id("UserNameOrEmail")).SendKeys("aa");
driver.FindElement(By.Id("Password")).SendKeys("aa");
driver.FindElement(By.XPath(".//*[#id='main']/form/div[3]/input")).Click();
driver.FindElement(By.XPath(".//*[#id='content-main']/div/div/a[3]")).Click();
}
[FindsBy(How = How.TagName, Using = "a")]
public static IList<IWebElement> LinkElements { get; set; }
public void LoopLink()
{
int count = LinkElements.Count;
for (int i = 0; i < count; i++)
{
driver.FindElements(By.TagName("a"))[i].Click();
}
}
[TestCleanup]
public void TearDown()
{
driver.Quit();
}
}
}
To run a unit test, put your cursor on the test method and click on the "Run Tests in Current Context" button (also in the 'Test' menu in VS).
See also https://msdn.microsoft.com/en-us/library/ms182524(v=vs.90).aspx.
You should also add some validation to your test method, so that VS can report whether it passed or failed. Add something like:
Assert.IsTrue(outcome);
where outcome is a boolean that indicates the success of your test method.
I have coded a simple test in visual studio using selenium which works in Firefox. However, I'm trying to run the same test on multiple browsers but I keep getting the same error that the drivers are not found in the directory or the PATH environment variable.
I have them downloaded and they are in the project I am working on. I've been trying all the different ways that I have found but nothing is working.
Can anyone help with this? Thanks :)
Here's a snippet of the code:
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;
namespace SeleniumTest2
{
//1 test multiple browsers
[TestFixture(typeof(ChromeDriver))]
[TestFixture(typeof(FirefoxDriver))]
[TestFixture(typeof(InternetExplorerDriver))]
public class ClickTestMetaLearning3TestUser<TWebDriver> where TWebDriver : IWebDriver, new()
{
private IWebDriver driver;
private StringBuilder verificationErrors;
private string baseURL;
private bool acceptNextAlert = true;
[SetUp]
public void SetupTest()
{
this.driver = new TWebDriver();
//Runtime.getRuntime().exec("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255");
baseURL = "http://url";
verificationErrors = new StringBuilder();
}
We have had to explicitly tell the ChromeDriver where it is located when constructing it :
_chromeDriver = new ChromeDriver(#"<path to the chromedriver.exe");