Is there a way in LeanFT / UFT Developer to get active element on OS level? - jenkins

My automation Framework consists of the following: UFT developer V15.0 (previously LeanFT) + Java + Maven + Junit.
UI Tests are executed by Jenkins on a dedicated VM (OS = Windows 10).
Many of my test cases include actual keyboard press, as this is a requirement of the AUT which is a web application.
My problem is that if tests are executed while user is not actually logged in - the cases which require to focus on the browser and press the keyboard - will fail.
When i use RDP to log in to the VM and minimize - tests will still fail.
when I use RDP, login to the VM and keep the screen open - test will focus successfully on relevant field and will pass.
I tried to disconnect using tscon using the below script, but still no use:
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console
)
As per my understanding - the problem seems to be focus.
To try and understand the source of the problem, i would like to try and get the actual active element which is currently in Focus on the OS level, just like getting the active element on browser ("document.activeElement.id").
As UFT developer is able to interact with Windows elements - is there a way to retrieve such info from the OS?
Or alternatively , solution to the original problem (keeping the focus on the running browser) would be great.

Related

Cannot start Batch service after upgrade to Platform update 32

i've upgraded test (onebox) environment to Platform update 32 and i cannot start Microsoft Dynamics 365 Unified Operations: Batch Management Service, there is a warning message that says:
In event viewer i see the following:
What i've tried so far:
1) Synchronized and built application from Visual Studio - fine
2) Checked if system is in maintenance mode - it is not
3) Tried to play with "Log on" tab of the service (on behalf of which user service is running) - didn't help
4) Checked if event log is full, cleared, extended allowed space for log twice and let it overwrite itself if it's full - didn't help
P.S. I suggest there is something with database (maybe any issue is enabled/disabled) but i cannot understand which one exactly (cannot find ScaleUnitFeature from event log anywhere).
I cannot restore/delete/replace database because it's important to keep all the data/set up on it

Difference in manual execution of running app in background and runAppInBackground() using appium

While executing runAppInBackground() for Android application through Appium the app gets restarted but when executed the same manually couldn't be able to reproduce the same. I Would like to deep dive into implementation of a runAppInBackground() method to reproduce the same issue in a manual way.
You need to look behind the code of runAppInBackground
From java client side (your test code) perspective, it is a single call to Appium server:
POST "/session/:sessionId/appium/app/background"
If you continue looking into where its implemented on server side, you finish with appium-android-driver function.
In short what it does:
Get current activity and package
Press physical Home button
Wait for time you provided as argument (seconds)
Bring up back in focus based on different conditions; from the code you can understand what activity is being started
Basically its a sequence of adb shell commands, that you can run from terminal.
My guess is that step 4 you did manually may differ from what Appium is doing: different activities/arguments for activity been called

Locally-run tests pass, but Jenkins tests fail; why, and how can I fix this?

I'm running a fairly large suite of python-based tests with a much larger number of steps on an Ubuntu Linux VM. When I run them via any number of methods manually (via the console) they all run and pass just fine.
After I ported them to a Jenkins server, four out of the thirty fail. I tried the usually recommended fix - increasing the wait time for keywords to work to 1s before every single click - so I'm fairly certain it isn't a timing issue. The site loads a lot faster than that on Windows, which I know is slower than Jenkins on Linux.
After Googling around a little for an answer, I found that apparently no one has come up with an accepted answer, either on this site or other Q/A sites.
Here's the error messages I'm getting from Jenkins.
ElementNotVisibleException: Message: element not visible
(Session info: chrome=61.0.3163.79
(Driver info: chromedriver=2.26.436382 (70eb799289ce4c2208441fc057053a5b07ceabac),platform=Linux 4.10.0-33-generic x86_64)
WebDriverException: Message: unknown error: Cannot read property 'innerHTML' of undefined
(Session info: chrome=61.0.3163.79
(Driver info: chromedriver=2.26.436382 (70eb799289ce4c2208441fc057053a5b07ceabac),platform=Linux 4.10.0-33-generic x86_64)
The other two are both element not visible exceptions identical to the first, both of which happen on a Click Button keyword that is not the first Click Button keyword in the test suite. The first one happens on a Click Element keyword that has worked perfectly since I wrote it, and the last one happens on tried-and-true JavaScript call to get the text of an element.
Why would something work locally on two different operating systems and then fail on Jenkins?
Why would something work locally on two different operating systems and then fail on Jenkins?
The most common might be that the jenkins system is running slower, and your tests aren't being hyper-vigilant about waiting for pages to finish loading before trying to interact with it. Jenkins boxes often can be under a heavy load, and if both the client and server are running on the same box, either or both could be contributing to the problem.
Another reason could be that you're running different versions of the browsers and/or selenium drivers on the jenkins box.
Another reason could be that the resolution of the (virtual?) displays is different, causing elements to be shifted to a different position.
The browsers on the jenkins box could have different profiles, resulting in a different set of plugins or antivirus software running. These can contribute to the speed at which a page renders, or could cause unwanted popups that cover portions of the screen.

Intern test framework hangs/does nothing when used with Appium 1.4.13 on an iOS device for mobile web

I just started looking into using the intern test framework to write functional tests for our mobile web apps. I'm looking to run these tests on actual iOS devices.
I setup Appium as the selenium server talking to the intern client. It works as expected on the simulator (although I get 'method not implemented' for many of the touch related methods).
I then decided to configure everything to work on my iPhone 6 plus, running iOS 9.0.2
After much wrangling with instructions from here, I got all the various pieces working in tandem (ios-webkit-debug-proxy, appium-server from the repo, etc.)
Finally, I decided to run my tests. When I run the test runner, Safari on my device starts up (via SafariLauncher App), and ios-webkit-debug-proxy and appium-server seem to be talking to each other. However, intern simply posts a 'created session on...' message, and then does nothing.
To ensure that the server was running properly, I decided to use a rest client to send it POST and GET requests using the JSONWire Protocol methods, and it seems to be loading the web-page url and responding to JSONWire requests. So clearly, something is going wrong with Appium talking to intern, or vice-versa.
Any help/insight on this would be greatly appreciated. Thanks!
I'm also in the unique position of having to run these locally, so using SauceLabs, BrowserStack, etc. is out of the question.
Got it working!!!
So the trick was to specify the proxyUrl config option.
My original conjecture was that there might have been some issues with basePath, etc., but I noticed my console.log statements that were outside of test cases were running properly.
That's when I noticed that the Safari page tried to navigate to localhost right after the test had started. This is my first time ever working with Intern or Appium or any Selenium stuff for that matter. Because you cannot access localhost (which in this case was meant for accessing the Intern server on my computer, since you're running the tests on your computer, and not on an external device), from the iPhone, I specified proxyUrl and proxyPort in the config, and specified my computer's local IP (192.168.x.x) and the Intern server port (9000). It still didn't work. I looked at the URL in Safari and noticed that it wasn't using the proxyPort field - so that the URL looked like: 192.168.x.x/__intern/clie... So I just tried to enter the port in the proxyUrl option - as that option's a string - 192.168.x.x:9000. And voila - it worked!!!
So hopefully this helps some other soul looking to have a native mobile test working with this setup!

Detecting if a process is started by IE in protected mode

I am writing a program that is used for simplifying the download of an application installer. The app is really simple in it's working: it just asks the BITS subsystem to download a ZIP from the net and decompress it on the user's desktop and run the second stage installer (the idea is that many of our end users are too dumb to be trusted with a ZIP download link and instructions on how to install the program).
Now, if a user runs IE 7+ in Vista/7, has UAC enabled and selects "execute" instead of "save as", then the program fails. In fact, all attempts to write to the file system or the registry fails due to IE's protected mode.
In order to work around this, I've tagged the executable to trigger a UAC prompt, which works fine. However, it will now trigger the prompt even if that trigger is unnecessary: the program is designed to do the download in the background and resume downloads if the user closes his session before it is done. Now, the UAC prompt is triggered every time the executable is launched.
I would like to detect the fact that I'm running inside the sandbox and, in that case, restart the process, this time with a UAC prompt (easy enough to do). I don't know how I can detect that situation, however, short of attempting to write to the registry.
Any idea ?
Call the IEIsProtectedModeProcess function.
A good document covering IE's protected mode is Understanding and Working in Protected Mode Internet Explorer.

Resources