Can Selenium Detect Which Port your .net Application is deployed to - c#

I recently started using Selenium for a .net project I'm working on.
It seems to work well however obviously you have to supply a URL like http://localhost:55555 or whatever address you are testing your application on.
My problem is that different people's computers in my team visual studio deploys to different port numbers on localhost so every time to get the tests to pass they have to find out what port there computer is deploying to locally and change it in the tests.
Does anyone know of a way I can detect the port number automatically so it doesn't need changed for each persons computer?
Thanks

I don't think you can do this with Selenium, because the port number is set randomly by VS during launch. However, the common solution to your problem is to have everyone use the same test port. This post shows how to do it.

Related

how to access usb port of client pc from web app

I have a web app. now I want to add "present and absent by finger print" to this. everything work fine in localhost (add finger,remove finger and etc). I send device port name to functions to do jobs.
but after publishing project I recognized that it can not find port in client's pc.
now I want to now how can I access specific port in client's pc after publishing web app?
PS:if you need to know part of code just say it to show you, thank you
Browsers don't let you to do it on purpose. However, you can create ActiveX objects, plugins or browser extensions to do it.
For example you can check this
I have understand the best way is windows application, so I did my job by creating c# windows application and did my job as well as I wanted.

How do I access a port remotely while debugging a .NET application in Visual Studio?

I am running Visual Studio in a VMWare Fusion virtual machine. When I debug my application, VS makes the application available on localhost:50609. I can use it effectively while in the vm itself. However, I would like to access this running instance from a simulated mobile app running in the host machine (an OsX host). This does not work -- the host simply does not see the running instance on the guest.
I started thinking this had something to do with firewalls or the way that the VM networking was set up. But, long story short, I'm pretty sure that the web application is hosted specifically on "localhost", and therefore is inaccessible outside of the localhost itself. Thus, I cannot use the guest OS's IP address on the virtual network to access the site. That is actually true even within the guest OS; i.e., I cannot access the site by using address 192.168.x.x:50609, but I can access it using localhost:50609 (again, this is from the guest, not the host).
So, I am convinced that VS or IIS (I think it's running IIS Express; whatever comes by default with VS 2013) is set up to only allow connections through localhost. That seems like a very good default for security reasons, but in this instance it's not what I want to do.
Can I make this debugged application accessible to an outside machine?
The fact that this is running using VMs is probably quite irrelevant, but I just wanted to give the specific setup. I've disabled Firewalls to test this, so it's not something like that.
[EDIT] The link pointing to how to do this in Web Matrix is useful, but I still lack the final step for how to change the default address in Visual Studio. I think it's only half the answer.
I struggled with this for two days and scoured the interwebs, following several "red herring" leads.
On MY system I finally got it working as expected. The key is that Vagrant (Docker) will not properly forward on 127.0.0.1. You need to set the server to listen on '0.0.0.0'. I knew that from my work with Rails in Vagrant. But it was not easy uncovering HOW to specify this in the DotNet CLI (IIS).
The answer is that you either add this to the call to WebHostBuilder in 'Program.cs' of your project:
.UseUrls("http://0.0.0.0:5000") // Take that, Docker port forwarding!!!
OR call the DotNet CLI like this:
ASPNETCORE_URLS="https://*:5000" dotnet run
I settled on a third option. I set an environment variable:
ASPNETCORE_URLS="https://*:5000"

Compile OpenVPN or SoftEther as DLL for use in C# WPF

I am trying to make a front end for my friends VPN Server hosting company. I have made most of the application with WPF and it is working as a standalone product. It downloads the server list from his website with JSON and populates the selection contents, does ping tests, and so on.
Now I am at the stage where I need to actually make it do something - my options seem to be OpenVPN or SoftEther.
I have tried to build OpenVPN as they recommend with VS2010, and SoftEther with 2008 Professional. I am really struggling to get a working build out of either, when their websites say it should just work if dependancys are met.
My understanding here is that I need to build the client from either of these 2 options as a dll, which I can then use as a lib into my C# Application and call any public facing connect functions and pass in the username and password entered in my GUI.
Am I on the right chain of thought? Has anybody out there successfully integrated OpenVPN or SoftEther into their own products?
I should mention I am totally lost with OpenVPN, but SoftEther builds for the most part but the installer is half empty and the drivers wont install for the virtual adapter either. Of course I can install them using the prebuilt binarys on the respective websites.

Browser opening, but failing to load localhost page--Selenium, MVC, C# .NET

I am starting to write tests for a project that is in its 8th agile sprint. I was brought on the team about one week ago.
Yesterday my Selenium tests were passing against the git master branch. I was accessing the http localhost address, opening it, running a test, and then closing the browser all from the Selenium code.
My team changed the access (somehow, don't quite understand) and the http localhost address changed. This was yesterday evening. Pulled the new code this morning from git.
I found the new address, and replaced it in my localhost constant. Ran the tests. Now the tests open the browser, no localhost info is entered into the url, test times out, test fails. All I changed was the localhost address.
When I just run start from the Visual Studio ribbon start button, the web app will open two windows in the browser (Firefox default). The team lead says that both windows are needed right now.
I am fairly new to Selenium (1 month and learning) and very new to .NET/Visual Studio/C# (day 4).
Researched the issue, only thing I have found that might make sense is creating an ASP.NET HTTP Module-- And I have read up on it, but don't know if it is THE solution.
If anybody has any other ideas, please let me know.
thx
a
EDIT : CODE
string URL = "http://localhost:54879/"; //unable to connect
....
driver.Navigate().GoToUrl(URL);
Had our local Microsoft guru look at what was happening. Tests run/console connects if I run after selecting start without debugging. I am v. new to Visual Studio, so I guess it was set up wrong in my tray and this makes it run properly.
In my case, the problem was that there was i needed to first run the programme without debuggen ( Debug > Start without Debugging).

Local Testing and Debugging Facebook iframe app (Windows Azure)

I wonder what the best way to test and debug facebook iframe applications locally (using the facebook c# toolkit and the azure toolkit)?
When i try to debug it's always starting the Compute Emulator on a different port.
Basically i want to have a special facebook iframe app pointing to a specific port on localhost (e.g. http://localhost:81) and after pushing the debug button that my app url (e.g. http://apps.facebook.com/myspecificappdev) is being started in my browser (with debug functionality).
I found this thread but unfortunatly this didn't help me a lot: http://azuretoolkit.codeplex.com/discussions/207487
What's the best way to debug such applications? Is their maybe a sample project which already has that part set up correctly?
Ok, here is what we do (at Thuzi). We set up an dedicated IIS web site for our code. We create a bogus domain like fbapp.mycompanysdomain.com and then we edit your machine's (or other machine's) Hosts file to point to the proper IP address. When we set up the site in IIS we use a host header which means that we don't need to worry about port numbers. When we debug we simply attach to the process.
So you point your web browser to the FB URL and it should always land on your web server (whether you are debugging locally or not). I know this sounds like a little more work, but it ends up being so much easier in the long run and better reflects what will ultimately happen. I realize if you are using any kind of storage then you will need to start that up, but it's still a lot easier this way..
If your app is simply a website, then you don't need to run the compute emulator to run it. I would setup the site so that it runs on IIS on a specific port, then debug the website project, not the cloud project.
There is a bit more to it than just that however. If you're using development storage then you'll need to start that yourself as it won't automatically be started when you debug the website. If you have a RoleEntryPoint class then you need to be aware that none of that code will be called. Also if you make use of anything in RoleEnvironment (like settings) you'll need to put a wrapper around those items so that they'll still work when not running under the emulation environment (RoleEnvironment.IsAvailable is very useful for detecting this). A setup like this is very useful during development because when you make small changes to CSS of JavaScript you don't need to restart the compute emulator to see your changes.
You're on the right track. You need to create a new facebook app and point the iframe / canvas / tab url to localhost with the specific port cassini chose for the project.
What I did to ensure the the windows azure app stays on the same port:
I placed this as a pre-build event:
"C:\Program Files\Windows Azure SDK\v1.4\bin\csrun.exe" /devfabric:shutdown
This makes it better but it's still switching port sometimes

Categories

Resources