objectivityltd / ocaramba Goto Github PK
View Code? Open in Web Editor NEWC# Framework to automate tests using Selenium WebDriver
License: MIT License
C# Framework to automate tests using Selenium WebDriver
License: MIT License
When i try to use MyEventFiringWebDriver i get an error when Using "JavaScriptClick()"
Message = "Unable to cast object of type 'EventFiringWebElement' to type 'OpenQA.Selenium.IWebDriver'."
Hello, thanks for the tool.
Breaks with:
One or more errors occurred.
Exception doesn't have a stacktrace
System.InvalidOperationException
Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line (SessionNotCreated)
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxOptions options)
at Objectivity.Test.Automation.Common.DriverContext.Start()
app.config:
<add key="browser" value="Firefox" />
packages.config
<package id="Objectivity.Test.Automation.Common.xUnit" version="3.1.3" targetFramework="net462" />
<package id="Selenium.Support" version="3.11.2" targetFramework="net462" />
<package id="Selenium.WebDriver" version="3.11.2" targetFramework="net462" />
<package id="Selenium.WebDriver.ChromeDriver" version="2.38.0" targetFramework="net462" />
<package id="Selenium.WebDriver.GeckoDriver" version="0.20.1" targetFramework="net462" />
<package id="Selenium.WebDriver.IEDriver" version="3.11.1" targetFramework="net462" />
In PATH: `"C:\Program Files\Mozilla Firefox".
FF 59.0.2 (64-bit)
Nuget Version: 3.1.8
DriverContext.CrossBrowserEnvironment
Prior to v3.1.8, since this was a string, we could have something like the following (a Browser-Platform string combo):
<appSettings>
<add key="CrossBrowserEnvironment" value="ChromeWindows" />
</appSettings>
<environments>
<ChromeWindows>
<add key="browser" value="chrome" />
<add key="os" value="Windows"/>
<add key="os_version" value="10"/>
<add key="resolution" value="1366x768" />
</ChromeWindows>
<ChromeMac>
<add key="browser" value="chrome" />
<add key="os" value="OS X"/>
<add key="os_version" value="High Sierra"/>
</ChromeMac>
<ChromeAndroid>
<add key="os_version" value="7.1"/>
<add key="device" value="Google Pixel" />
<add key="real_mobile" value="true" />
</ChromeAndroid>
</environments>
Since it was a generic string, it would populate the settings
properly:
NameValueCollection settings = ConfigurationManager.GetSection("environments/" + this.CrossBrowserEnvironment) as NameValueCollection;
But with the new change to BrowserType in v3.1.8, we no longer have this flexibility in naming the CrossBrowserEnvironment
to suit our needs...Thoughts?
NOTE: This is NOT a blocker, as I have a workaround by handling it DriverContext_DriverOptionsSet handler...
How do i Write linq on getElment or getElements methods.
I am trying to select an element from a list of item based on the text property.
ex:
lstMainMenu = new ElementLocator(Locator.CssSelector, "#sideMenu >li")
var mainmenu = this.Driver.GetElements(lstMainMenu);
var x= mainmenu.Where(e => e.Text.Contains("HOME"));
then i will do some action.
i am getting below error:
Let me know if i am using this methods in correct ways.
Name | Value | Type | |
---|---|---|---|
Error | Evaluation of method System.Linq.SystemCore_EnumerableDebugView`1[OpenQA.Selenium.IWebElement].get_Items() calls into native method Microsoft.Win32.SafeNativeMethods.QueryPerformanceCounter(long&). Evaluation of native methods in this context is not supported. |
thanks
Vipin
Hi -
I am using your framework and trying to integrate to SauceLab.
Still it throwing up error.
Where should I pass credentials to the Remote Webdriver Hub ?
Hi, Can we have some mechanism here so that we can pass which browser to execute tests against from CI tool or from command line?
Hi - I have cloned this specflow automation framework. When i click on run button i see below error message . Please help me on it.
Visual studio cannot start debugging because the debug target 'C:\users].......' is missing. Please build the project and retry , or set the outputpath and asseblyname properties appropriately to pint at the correct location for the target assembly
CS50001 Program does not contain a static Main method suitable for an entry point
Very well written framework some excellent ideas, thank you! 👍
One question, if I wanted to run the Nunit tests or any other tests, in parallel, on different browsers, how can that be achieved getting data from app.config file?
Regards
Please add an example for BaseConfiguration Class.
TODO (optional): Describe a specific scenario you would like to see addressed.
Help Topic: http://objectivityltd.github.io/Test.Automation/html/f4719844-316f-7604-9f30-52e4cb9631e4.htm
All my tests run sequentially in the same instance of a browser, which causes problems if tests need to isolate behavior per session.
I realize spinning up the browser is an expensive operation, but it seems necessary in certain circumstances. I'd be willing to try to force a delete of cookies between tests, but I can't see where Driver.Manage.DeleteAllCookies() is an option off the DriverContext in the TearDown method.
As always, am I missing something obvious?
Hello.
someElement.GetElement() throws exception "cant cast "EventFiringWebElement" to "OpenQA.Selenium.IWebDriver".
Any tentative timelines for the same?
If Selenium tests generated for xunit are run using xunit test runner then output is placed in the console. And Test.Automation runs a WebDriver such that it outputs into the same console, see this line. How to run a WebDriver in a separate window. So that CI process can capture output of it separately? Should it be somehow ChromeDriverService as per this doc?
I have your selenium framework with me
I have the example class
Now I want to use these to test a web application (suppose google.com)
Could you please advise the steps.
Hi, thanks for this lib!
How to make it to use PhantomJs? No such driver listed at Test.Automation/Objectivity.Test.Automation.Common/BrowserType.cs
and it throws System.NotSupportedException : Driver None is not supported
when <add key="browser" value="PhantomJs" />
When i am running Mstest, Chrome driver is lanched and test cases are exectuted.
I created build pipeline in VSTS for the same. I tried to Run the test cases, Chrome driver is not launched, and test cases are failing as this.DriverContext.Start(); thows exception regarding chromedriver path.
So to resolve this i made changes in app.config as suggested in BaseConfiguration.
I am getting below error. " (unknown error: DevToolsActivePort file doesn't exist) ".
Provided Path of Local ChromeDriver:
I also added ChromeArguments in App.config
May be i am missing something, couls guys please help.
Error:
OpenQA.Selenium.WebDriverException: 'unknown error: Chrome failed to start: was killed
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:\Driver\chromedriver.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5),platform=Windows NT 10.0.17134 x86_64)'
https://github.com/ObjectivityLtd/Test.Automation/wiki/Selenium-Parallel-tests-execution
I'm using NUnit with SpecFlow. Is it possible to run features parallel in Chrome locally? I don't want to setup Grid or run on Browserstack yet.
I started using Test.Automation, but now am thinking of moving to Selenium Grid. It seems this framework does not support it.
I am thinking of implementing it. Just want to check first whether it is already planned or under development, not to duplicate effort.
Hi,
I've added a reference in app.config to an extension I need to run (uBlock since some internal firewall issues cause 3rd party scripts to take forever to load). I have installed the extension on the default profile, and it's present when I launch FF manually, but from Selenium, FF loads without any add ons.
The reference I made in app.config loads the .xpi in previous versions of FF (e.g. 47.0.1) but doesn't load it in FF 54.0.1.
I also changed the reference to not load the default profile, but when loading a custom profile (which DOES include the add on in FF 54.0.1) test start times were upwards of 1 minute.
Is this a limitation in this recent build of Firefox, or have I (yet again) tried to implement it incorrectly? What should the value reference be for the plugin if the key value is the path?
I’m automation tester. I’m trying to identify best test automation approach. My application is developed in C# (DB : SQL Server) and I need to write test automation scripts for UI, DB and REST services. I have below two options available.
Thanks for your help in advance !!
Hi
This framework is powerful, is it possible to add another feature to connect HP ALM (Quality Center) to run or update back results using ALM API.
Thanks
Thulasi
var asd = this.Driver.GetElements(new ElementLocator(Locator.CssSelector, "#checkboxes input"));
always return the same exception
Our implementation of the Kendo dropdown list has a select
element instead of the input
element. I was able to interact with our dropdowns by updating the target element from input
to select
here:
https://github.com/ObjectivityLtd/Test.Automation/blob/960057855c402fd9f145cbf21685c7c0d771bd8d/Objectivity.Test.Automation.Common/WebElements/Kendo/KendoSelect.cs#L42
The Telerik demo page has 2 dropdowns. The first one uses input
, second one uses select
.
Hi,
To leave out passing DriverContext throughout the tests I have moved it to a custom singleton. Tests became much clearer for QA Engineers.
Was thinking about the reason It is not implemented as such. I can PR my changes if you're interested.
Eduard
Hi, I'm trying to use the DataDrivenHelper class in the latest version for NUnit (3.1.7).
My project can't find the DataDrivenHelper though.
I've even tried the example imports:
https://github.com/ObjectivityLtd/Test.Automation/wiki/NUnit-DataDriven-tests-from-Xml,-CSV-and-Excel-files
using Objectivity.Test.Automation.Tests.NUnit.DataDriven;
It can't find the Tests
namespace after Automation. Am I missing something?
Error CS0234 The type or namespace name 'Tests' does not exist in the namespace 'Objectivity.Test.Automation' (are you missing an assembly reference?)
Regards
I was wondering if there is a reason why the framework accesses elements like this:
private readonly ElementLocator
linkLocator = new ElementLocator(Locator.CssSelector, "a[href='/{0}']"),
basicAuthLink = new ElementLocator(Locator.XPath, "//a[contains(text(),'Auth')]");
rather than the Selenium.Support method:
[FindsBy(How = How.Id, Using = "Username")]
private IWebElement _username;
[FindsBy(How = How.Id, Using = "Password")]
private IWebElement _password;
[FindsBy(How = How.Id, Using = "login-button")]
private IWebElement _loginbutton;
I'm curious whether this is a conscious design decision. If so, why?
Hey there! I'm embarking on using Ocaramba as a part of a larger framework test module project. We use MSTest as our unit framework, and I'm wondering EXACTLY what I would need to add to my package dependency for the project in order to reap the benefits of ALL of Ocaramba.
Presently, I have added the Ocaramba.MSTest nuget package to my manager, however the NLog references are not being honored, even though it appears that the package has downloaded.
Do I have to explicitly include all of the source code from Ocaramba in my framework project, or is it all included as part of the Ocaramba.MSTest nuget?
Thank you!
private InternetExplorerOptions InternetExplorerOptions
{
get
{
// retrieving settings from config file
var internetExplorerPreferences = ConfigurationManager.GetSection("InternetExplorerPreferences") as NameValueCollection;
var options = new InternetExplorerOptions
{
EnsureCleanSession = true,
IgnoreZoomLevel = true,
};
// set browser proxy for IE
if (!string.IsNullOrEmpty(BaseConfiguration.Proxy))
{
options.Proxy = this.CurrentProxy();
}
// custom preferences
// if there are any settings
if (internetExplorerPreferences == null)
{
return options;
}
// loop through all of them
for (var i = 0; i < internetExplorerPreferences.Count; i++)
{
Logger.Trace(CultureInfo.CurrentCulture, "Set custom preference '{0},{1}'", internetExplorerPreferences.GetKey(i), internetExplorerPreferences[i]);
// and verify all of them
switch (internetExplorerPreferences.GetKey(i))
{
case "EnsureCleanSession":
options.EnsureCleanSession = Convert.ToBoolean(internetExplorerPreferences[i], CultureInfo.CurrentCulture);
break;
case "IgnoreZoomLevel":
options.IgnoreZoomLevel = Convert.ToBoolean(internetExplorerPreferences[i], CultureInfo.CurrentCulture);
break;
}
}
return options;
}
}
I am really impressed with the Automation framework. It's really amazing.
We use Sencha ExtjS for our web application which generates dynamic ids. Any idea how we can build the test case around it smartly.
Please add an example for DriverContext.CrossBrowserEnvironment Property.
TODO (optional): Describe a specific scenario you would like to see addressed.
Help Topic: http://objectivityltd.github.io/Ocaramba/html/269c9e20-25d7-ec0d-f9cd-26b9dfce3de4.htm
I have cloned specflow framework and trying to run. Please help me on running thus framework. I did not see main method on it.
When a test is run on Chrome (Windows/Android) combination (BrowserStack)…
System.InvalidCastException:
Unable to cast object of type 'OpenQA.Selenium.Remote.ReadOnlyDesiredCapabilities' to type 'OpenQA.Selenium.Remote.DesiredCapabilities'.
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
at Objectivity.Test.Automation.Common.DriverContext.SetCapabilities()
at Objectivity.Test.Automation.Common.DriverContext.Start()
how to get HTML reports with this frame work for selenium tests using MS Test frame work
Please add an example for BaseConfiguration Class.
TODO (optional): Describe a specific scenario you would like to see addressed.
Help Topic: http://objectivityltd.github.io/Test.Automation/html/f4719844-316f-7604-9f30-52e4cb9631e4.htm
OS: Win 10
FF: Anything > 47.01
Selenium: 3.4
Geckodriver: 0.18.0
I've got a project with ObjectivityNUnit package installed per the getting started section of the wiki. FF 47.01 runs fine, Chrome runs fine. I know in Selenium 3 you need to automate through Geckodriver for FF versions > 47, so I installed most recent Geckodriver binary and added it to my path.
When I execute a test with newer FF (I've tried 32 bit versions of every major and several minor releases between 47 and 54), the browser launches but never navigates. Stepping through it, the test stops in the OneTimeSetup
at this.DriverContext.Start()
. error as below:
Result Message: OneTimeSetUp: OpenQA.Selenium.WebDriverException : Failed to start up socket within 45000 milliseconds. Attempted to connect to the following addresses: 127.0.0.1:7055
I honestly feel like I am missing a step, does Geckodriver factor into this at all?
Good afternoon,
Is is possible to make the Kendo RemoteWebElements work for the Angular version of the controls. The angular drop-down as an example can be seen here: https://www.telerik.com/kendo-angular-ui/components/dropdowns/dropdownlist/
As expected, when trying to initialise a KendoDropDownList element results in the following error, because the main part of the control i not a span, and the span below it doesn't have the k-widget class
NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"./ancestor-or-self::span[contains(@class, 'k-widget')]//*[@id]"}
Thanks in advance.
Hello - I have a Specflow based test project that I based on your example using the ProjectTestBase.cs. provided. When I run the test for my features, I can walk through the code for ProjectTestBase and the DriverContext initializes properly for the driver that I am using but when the BeforeTest method goes out of scope, so does the DriverContext and scenarioContext.
As I debug my version of CommonSteps, the DriverContext is passed in but with a null driver member variable. ScenarioContext is null too.
What modificationx should I include in my steps classes in order to get them to work with the DriverContext and ScenarioContext from the ProjectTestBase class:? My step classes, like your CommonSteps class are not derived from any base classes.
Thank you
Chris
More info: https://sites.google.com/a/chromium.org/chromedriver/logging/performance-log
If not thru app.config
, it would be good to at least expose the DriverContext
properties (e.g. ChromeProfile
) so we can update it before the Start() method is called (similar to this)
Hi,
Very well written framework, thank you for all your efforts.
I'm using SpecFlow with NUnit and trying to run tests in parallel using Zalenium however I'm getting an error when running tests.
I have set the below properties in App.config file.
<add key="browser" value="RemoteWebDriver" />
<add key="DriverCapabilities" value="Chrome" />
<add key="RemoteWebDriverHub" value="http://localhost:4444/wd/hub" />
Below is the error I'm getting.
Does anyone here know what this error is and how it can be resolved?
Thank you,
My scenario requires that I have more control around setting browser capabilities. I have created a branch which creates a new event on the DriverContext that allows me to hook into the pipeline to add more capabilities at runtime.
The branch is here: https://github.com/gregpakes/Test.Automation/tree/custom-capabilities
I haven't created a PR as it contains checkins from other branches I have submitted PRs for.
Please let me know if this is of interest to you and how I should go about submitting a PR.
Hi I am trying to mouse over to an element in IE browser using this Objectivity MS Test frame work. Mouse hover is not working. Please help me in resolving this issue. I also added the following settings in appconfig.xml
As the title says, I'm running Ocaramba.Features (3.1.15) with SpecFlow 2.4.1, and every time I run my tests in VS2015 Pro Update 3 (unfortunately, command-line testing is off limits at this job so I can't even test it), it launches 5 instances of Chrome per test.
I have only slightly modified my ProjectTestBase -- the changes are as follows....
[Before]
public void BeforeTest()
{
/* Everything is the same up to this line... */
this.DriverContext.DriverOptionsSet += DriverContext_DriverOptionsSet;
this.DriverContext.Start();
this.scenarioContext[nameof(this.DriverContext)] = this.DriverContext;
}
private static void DriverContext_DriverOptionsSet(object sender, DriverOptionsSetEventArgs args)
{
if (args == null || args.DriverOptions == null)
{
throw new ArgumentNullException();
}
args.DriverOptions.AddAdditionalCapability("useAutomationExtension", false);
}
And my App.config is unchanged other than the host value, which is aimed at my localhost.
I'm not sure what I need to change to get down to one instance of Chrome.
I can share my code, but this job has gists blocked, and has the machines locked down so hard that I can't push code up. If you need to see anything, I'll have to paste it here. :(
Performance Measure - need improvements (report on the specific page/action in the log)
Hi Team of the Objectivity Ltd.
Thank you for the great framework. There I have improvement request.
As far as I can see the performance measured in the following implementations:
public class PerformanceHelper.
There is line in the function 'public void StopMeasure':
Logger.Info(CultureInfo.CurrentCulture, "Load Time {0}", this.MeasuredTime);
Which produces line in the Log as:
|Info|Objectivity.Test.Automation.Common.Helpers.PerformanceHelper.StopMeasure|Load Time 1316
Looks like it is would be very helpful if the function will just return the measured value instead of putting it in the log.
There would be easier to report on specific actions (page loads). There is property which is not accessible from the outside:
private long MeasuredTime
Another option to expose the duration is: timer.ElapsedMilliseconds, which is also private.
My implementation would be as the follows (in the PerformanceHelper class):
public double StopMeasureDuration(string title)
{
this.timer.Stop();
var savedTimes = new SavedTimes(title);
this.MeasuredTime = this.timer.ElapsedMilliseconds;
savedTimes.SetDuration(this.MeasuredTime);
this.loadTimeList.Add(savedTimes);
return this.MeasuredTime;
}
Please let me know if you see this as feasible implementation!
Thank you!
Hi,
can you provide more details on how the reporting would be when we run mutiple test cases? Can we integrate this with TFS and define TFS builds to run the solution?
Please add an example for Verify Class.
TODO (optional): Describe a specific scenario you would like to see addressed.
Help Topic: http://objectivityltd.github.io/Test.Automation/html/8097f44b-5724-ad70-5f15-e9571d0dd43e.htm
Hello everyone, thank you for all your efforts.
I am trying to run the same Feature file (Login.feature) test steps for Google and IE in parallel, but I am running into some issues. As you can see below, the LoginFeature test class in Login.feature.cs is not getting appended with an NUnit parallelizable atribute ([NUnit.Framework.ParallelizableAttribute()])
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "2.2.0.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("Login")]
public partial class LoginFeature
{
Changing and saving the App.config is not having any effect on LoginFeature test class even after I click "Yes" to the usual "Do you want to regenerate the feature files now." message.
Here are my setting from App.config
I changed the os_version from 10 to 7 since my PC is running on Windows 7.
The app only launches IE, not Chrome.
Your help will be appreciated.
Thank you.
Burak
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.