i have created unit tests for my web project but i have come across an error whereby the tests are being ignored and Visual Studio 2012 is running my localhost instead. i cannot use localhost to run my tests as there are a lot of java resources and overlays which aren't displayed. Essentially that is the point to UI testing that you test the correct interface.
The code i used in a blank project - runs perfectly and completes the test with no issues but since i need to include this into my web project, i need a way to stop Visual Studio running the localhost and get it to execute the console application test so that my selenium webdriver can run the test properly.
using: Visual Studio 2012
Selenium (webdriver)
chrome driver (latest version)
c#.Net
example code:
IWebDriver _driver;
ChromeOptions options = new ChromeOptions();
options.AddArgument("--start-maximized");
_driver = new ChromeDriver(options);
_driver.Url = "http://theURLimTesting.com/";
var verificationErrors = new StringBuilder();
_driver.Navigate().GoToUrl("http://theURLimTesting.com/");
_driver.FindElement(By.Id("Username")).Clear();
if anyone could help me and provide a solution as to how to run these tests without excluding them from the project and without having to create a proxy - i would be very grateful, as i am very much a novice.
UPDATE: as #mutt 's answer helped steer me towards the right direction with being able to resolve my question i marked the answer as right - i have managed to configure the error and create a work around and tweaking some settings to get this to work and now i can run all tests inside of the web application properly and they all function properly with executing and closing themselves in the background when done.
Separate your unit tests from the web project and it should work. Since you have them together your webapp probably has a default start page so when you "play" it will load that and VS is scoped to that browser running on IIS Express instead of the regular browser.
Personally I would have thought it would still work since Selenium is hitting the driver package that is referencing the browser, but I'm not sure what all VS is doing when it runs the webapp. If you want it with the console then move all your unit tests to the console project and they should still work on the WebApp because they will be hitting the server version and not the locally run project.
Update:
It looks like it is process bound. So Selenium and visual studio are sharing the same process. VS2008 debugging with firefox as default browser - how to make the debugger stop/close on exit?
Update2:
It looks like you should be able to determine if the process is being utilized. Then the question would be can you just kill it in your unit test script so that it will be forced to create a new one... Programmatically determine if code is running under IIS Express
Related
I'm trying to expand a sudoku web application that I've checked out locally with visual studio 2022, namely this one: https://github.com/michel-kraemer/sudocle
My goal is to implement additional functionality and I'm using this as a learning experience in frontend development since I'm currently only doing backend. I can get the application to run in my localhost using node.js as detailed in the readme and I can modify some very basic things (e.g. changing texts) but to really get started, I would like to debug the application as it's running on my local server. The expectation is that I could set breakpoints in function that I want to modify to see the state of variables at runtime.
This is where I'm stuck. I've tried attaching the debugger to various processes and I can get it started from the next.config.js file, however I think it's not connected to my localhost then and I'm not sure how to trigger any functions from that point. Maybe I'm also misunderstanding the functions of a debugger in a web application.
For what it's worth, those are the sites I've been reading trying to solve my issue, so far with no luck:
https://github.com/Microsoft/nodejstools/wiki/Debugging
https://learn.microsoft.com/en-us/visualstudio/debugger/troubleshooting-breakpoints?view=vs-2022
https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_auto-attach
F5 or Start Debugging Button is Greyed Out for Winform application?
https://learn.microsoft.com/en-us/visualstudio/debugger/debugger-feature-tour?view=vs-2022
I hope a more experienced dev can help me out here.
I have a web application that is written in node.js and gets started using a gulp command. When the application first starts, before the server is running, debug points may be hit in WebStorm (or in any IDE or command line tool). However, after the server is running and I go to the interface in my localhost I can no longer hit debug points inside the application. This is not being caused by client side code as the debug points are in server code.
I have read the answers that involve using the node-inspector and that has not solved my problem because of configuration files that are not getting read when starting the debugger in node inspector.
I'm a bit surprised that there is so little on here about this issue. Is it not a normal problem that other developers face? Thanks in advance for the help.
My workaround for this may not be sufficient for every case. I was modifying JavaScript files and didn't actually need the configuration files, after loading, to be able to test my changes. I did the following:
Wrote a line in my app.js file that set the variables I needed. (these would have been tasks ran in Gulp)
I then started the app as a Node.js app and was able to debug it as normal.
If any of my views had been updated, or anything else that was being managed by Gulp, then I could have simply stopped the server, started it again via the Gulp command, and then stopped again and restarted as a Node.js app.
This did not solve the issue in my OP but it was a good enough workaround to get debug points in the JavaScript.
We have a windows client that our QA team wrote coded UI tests for. I'm trying to get OpenCover to work so we can see how much of the app their tests are really hitting. They wrote their tests using a custom framework on top of the MSTest framework.
Their framework uses ApplicationUnderTest.Launch to start the application as different users to test security settings. I can capture coverage of the test dlls but the application it self.
I've forced the app to build in 32bit, made sure all pdbs are present in the folders and included the pdb directory in the targetdir as well.
Has anyone else seen this issue? I also tried replacing my batch file with a wrapper exe and got coverage for that but not the main application. Everything is running as the user they are starting the application as who is also an admin on the machine.
The command I'm running is:
C:\Users\kkindt.CORP\AppData\Local\Apps\OpenCover\OpenCover.Console.exe -register "-target:C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" -output:C:\CodeCoverage\CollectionResults\CodedUICover.xml "-targetargs:C:\CodeCoverage\Tests\EllisWinAppTest.dll /Platform:x86 /Framework:framework40 /Tests:LaunchEllisTest"
I strongly suspect it is due to how you are launching the application under test
OpenCover is a .NET profiler and for .NET application to be launched with a profiler attached requires some environment variables to be available to the new process. I suspect that ApplicationUnderTest.Launch does not propagate all the current environment variables and so the profiler does not start and therefore does not report coverage.
To get this to work you should look into using the ApplicationUnderTest.Launch overload that uses a ProcessStartInfo and then you need to propagate the following environment variables
Cor_Profiler
Cor_Enable_Profiling
OpenCover_Profiler_Key
OpenCover_Profiler_Namespace
OpenCover_Profiler_Threshold
OpenCover_Profiler_TraceByTest (if available)
The Cor_* are required by the runtime to launch a profiler and the OpenCover_* entries are to allow the profiler and the host to find each other - a list of these environment variables are available on github
I have been asked to write an automated test suite. The project manager has asked me to use Visual studio CodedUI, but this has raised issues with the development team who don't want me to have access to the source code, which I understand.
I normally use Selenium Webdriver for automation.
If I was to write tests in CodedUI would I need access to the source code and would my tests interfere with the source code i.e. code could go out of sync and add additional dependencies
or I should I be able kept my tests completely independent like I can with Selenium WebDriver?
You don't need access to the source code, just the application and visual studio.
I don't agree with the position on blocking access to the source code.
Not being able to build and test against the latest code will cause testing to lag far behind development. Development and testing should really happen at the same time.
Test early and often:
http://msdn.microsoft.com/en-us/library/vstudio/ee330950%28v=vs.110%29.aspx
A little context:
I'm trying to build and run the unit tests for the source of the Selenium IDE plugin. Everything builds correctly (through maven commands, et al) and the unit tests fire up an instance of Firefox. However, the jsUnit testRunner.html page freezes whenever a chrome://-accessed uri path is encountered.
I realize there are a LOT of moving parts in this situation, but I'm fairly certain/convinced that it's centered on an inability to access chrome:// paths within the markup of testRunner.html.
I am working with:
Firefox 3.5.7
Selenium IDE 1.0.3 source
Maven 2.2.1
Windows XP box
I've already taken into account various known required tweaks for such execution in a Firefox 3.X environment (setting security.fileuri.strict_origin_policy = false in the profile preferences and adding contentaccessible=yes to the chrome.manifest file of selenium-ide), but to no avail.
Does anyone have any insight into such an issue? I know my specific situation includes building Selenium IDE, but my gut is telling me it's a simple browser security situation.
Any and all insight is much appreciated!