I'm supposed to test the reaction of a page when net is disconnected while on the page. (errors get thrown).
My Method does the following - the page loads, i disconnect net, verify if the right actions take place and then connect the net back up and continue the next set of actions. This method is a part of an ordered test.
I have the code that makes this possible, and works as expected while running the test on Visual Studio (VS 2013).
I tried this in two ways using C# (Coded UI) - by disconnecting the LAN(bad option) and by disconnecting the WAN(by disabling the DNS which poses an issue since MTM tries to connect with my system, but fails since theres no DNS).
Both of these are not really helpful while i try to run my ordered test on MTM.
When I try and run the ordered test on MTM, it just does not work! I get the errors 'Your Team Foundation Server is currently unavailable' or 'An error occurred while communicating with Agent'.
The destination for the test run is my own system.
Is there anyway i could disconnect the internet AND not affect MTM while this happens ?
Any ideas/alternate solutions will be much appreciated !!
Thanks!
Related
currently in my 2nd week of trying to work out why a certain test runs perfectly locally but fails when being kicked off by a VSTS agent.
Program flow:
Select an row from a table
Click Verify button
CSS overlay darkens the screen, spinner in the middle
Toaster pop up in the bottom left saying Verification starting
About 1.5 minutes of time passes, spinner spins
CSS overlay removed
Toaster pop up bottom left, successful verification
I have screenshots and debug output on everystep of the way and the failure is at the "Waiting for CSS overlay to be removed" stage. It times out waiting for it, now matter how long the timeout.
Screenshot shows the CSS overlay and spinner still spinning even though the verification process completed successfully. Its almost as if it's stuck in time.
Scenarios and results:
Run from Local Visual Studio - PASS
VSTS Agent - FAIL
Manually run on VSTS Agent by remoting in and passing the exact commandline as the build - PASS (This is what infuriates me!!)
Downgrading / upgrading Webdriver - no difference
Headless / full mode - no difference
Using different types of waits - no difference
Waiting for Toaster pop ups instead of CSS - no difference
One thing to note from the documentation:
Agents that are configured to run as service can run Selenium tests
only with headless browsers. If you are not using a headless browser,
or if you are running UI tests for desktop apps, Windows agents must
be configured to run as an interactive process with auto-logon
enabled.
The fact that you also tried to run Headless might mean that even if you are running as a service and still got errors, this might not be your issue. In some cases, I have had issues with remoting to the machine messing up future test runs or video recording by logging out the user or changing the screen resolution. The documentation continues about ways to prevent this:
If you use Remote Desktop to access the computer on which an agent is
running with auto-logon, simply disconnecting the Remote Desktop
causes the computer to be locked and any UI tests that run on this
agent may fail. To avoid this, use the tscon command on the remote
computer to disconnect from Remote Desktop. For example:
%windir%\System32\tscon.exe 1 /dest:console
In this example, the number '1' is the ID of the remote desktop
session. This number may change between remote sessions, but can be
viewed in Task Manager. Alternatively, to automate finding the current
session ID, create a batch file containing the following code:
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console
)
Save the batch file and create a desktop shortcut to it, then change the shortcut
properties to 'Run as administrator'. Running the batch file from this
shortcut disconnects from the remote desktop but preserves the UI
session and allows UI tests to run.
I'll answer my own question: We created a new agent which was an auto login. We watched the test run and pressed F12 and there, in the console, was an error.
It was trying to trim() on the username, the test account looked like it had a username but I guess it didn't really. So the system, when run by the agent, was throwing an error and not handling it.
Handled the error and everything went through swimmingly. Very long and frustrating road to get to here! Hope this helps someone in the future.
Please check Azure DevOps Hands-On-Labs to get started with Automating Selenium Tests in Azure Pipelines. Hope this helps...
VSTS will run Selenium and the browser as local admin. The browser will refuse that when started in sandbox mode.
Check for articles related to running Selenium as local admin
I have been able to run Selenium test locally on my test machine using a simple webdriver setup such as IWebDriver driver = new FirefoxDriver(); driver.Url = "http://www.testedApp.com"; and running the tests through Microsoft.VisualStudio.TestTools.UnitTesting;, but when I deploy the test through Team Foundation Server vnext Build step "Test: Run Functional Tests" https://www.visualstudio.com/en-gb/docs/build/steps/test/run-functional-tests I get various errors that all seem to relate back to not being able to create a driver in the first place.
I am deploying the selenium tests onto remote machines (either windows Server 2008 R2 or 2012) that have the application to be tested already installed. It doesn't seem to matter if I put the url to driver.Url = "http://www.testedApp.com"; or driver.Url = "http://www.localhost/testedApp.com"; the machine (which looks to still be running from the TFS server machine, not the machine I have deployed the tests onto) appears to be failing at timeouts which led me to this answer on Stack Overflow
Selenium Error - The HTTP request to the remote WebDriver timed out after 60 seconds
After trying all the options there, looking further, I discovered the Selenium Server and RemoteWebdriver (the RemoteWebdriver actually being in my error very deep down)
I am also running the test agent on the remote machine under an Administrator account, so would assume the UI access wouldn't be a problem, but the error also persists if I am using Phantomjs as a browser.
So, I guess my real question is, in order to run a test successfully on a remote machine from the TFS machine, will I need to install and run a Selemium Server (and therefore create my drivers through a RemoteWebdriver)?
If so, would this Selenium Server go on the TFS machine, or the remote machine I am attempting to run the tests on?
I just wanted to update this with my solution.
I managed to get the vnext Build step "Test: Run Functional Tests" working without using remoteWebDriver or running a Selenium Server with nodes.
I had all the correct trust levels and ports opened, my problem was that I didn't realise that I needed to have the agent running the tests being Authenticated with a PAT Token (in other words, it requires ssl to operate successfully) (DOH!)
I also ran into a problem where the domain policy kept resetting the Group Policy for autologon to 0, which I have got around by running a script to reset before I kick the tests off.
Hope this helps somebody else.
And I apologise in advance if my question initially led to some false assumptions.
But, needless to say, I am grateful that I am not required to maintain the selenium servers (or Octopus deploy), and that Vnext build is adaptable enough to handle this all in house.
Vnext still has a way to go to become completely adaptable to my needs, but it is a great start (imo)
You will need a selenium server or node on every machine running a browser.
I am using vsts 2012 and IE 11 for web performance testing of MVC web application. So I did the following steps:
Create web and load project
Recorded one web test for "create user" scenario
Checked in actual database and on UI whether created user count=1 or not
Here I have not re-run the recorded test but still I can see two users have been created. I have only recorded one test and have not run that test. So I expected the user count to be 1.
Is there any issue with web test recording for first time?
When we run the test a second time then it shows the correct user count.
When you click the "stop recording" button for a Visual Studio web test the test is rerun by Visual Studio. You can see some of this happening behind the popup about detecting dynamic parameters. After the that detection has completed and Visual Studio is ready to accept further commands you will see in the Test Results window some details of that execution. Often this will show that the test failed, but don't worry about that failure.
For your specific question, I believe that one record was created by you when you recorded the test. The second record was created by the test executed for the purpose of detecting dynamic parameters.
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).
We are developing some functional tests using Selenium 2 framework on a FireFox 10 environment and we are in trouble with this special functionality:
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
We are trying to setup the implicitly wait time to avoid sleep statements into our page objects. We we run the tests local or using a remote web driver everything works flawlessly, but when executing inside the TeamCity 7.0.4 server we got this unexpected modal:
SetUp method failed. SetUp : System.InvalidOperationException : Modal dialog present (UnexpectedAlertOpen)
at ... [Stack trace] ...
Unfortunately we don't have access to see what modal is really showing up. If we turn back using sleep timers in place of the driver configuration, everything works.
Obs: We are sure that the TeamCity environment is setup just like in our local machines. Including the FireFox version.
Any ideas?
Thank you!
Start TeamCity Agent as normal process under your account (and not windows service) and wait what kind of dialog you will see.