Coded UI Tests don't run on one machine, but run on another - coded-ui-tests

My co-workers and I are working on a Coded UI project. We both have the same version of the project thanks to TFS, but on his computer all the test cases run, and on mine they don't. They used to run perfectly fine on my machine until one morning they decided to not work. I always keep getting the same error that the UI Test Controls are not found, even though the mappings are correct. Let me remind you that they work perfectly fine on my co-workers machine. We also have the same version of IE (11).
What could be the cause for this?
Thanks for the help in advance.

My co-worker seemed to resolve the situation, but we still don't understand why the previous version of the code worked for everyone but my machine. The problem occurred in our LaunchBrowser method which would use 2 different instantiations of the browser variable. He got rid of the unnecessary one and the playback commands and seemed to have fixed the problem.
Below are two versions of the code, the previous one and the newly written one:
Old:
public static void LaunchBrowser(string url)
{
GlobalVariable.browser = new BrowserWindow();
CloseAllBrowsers();
BrowserWindow.CurrentBrowser = GlobalVariable.BrowserType;
Playback.PlaybackSettings.WaitForReadyLevel = Microsoft.VisualStudio.TestTools.UITest.Extension.WaitForReadyLevel.Disabled;
GlobalVariable.browser = BrowserWindow.Launch();
System.Uri URI = new System.Uri(url);
GlobalVariable.browser.NavigateToUrl(URI);
Playback.PlaybackSettings.WaitForReadyLevel = Microsoft.VisualStudio.TestTools.UITest.Extension.WaitForReadyLevel.UIThreadOnly;
GlobalVariable.browser.Maximized = true;
if (BrowserWindow.CurrentBrowser == "Firefox")
{
Mouse.Click(_fireFoxAuthOK);
}
Logging.WriteLog("Browser was navigated to " + url + " in browser: <" + GlobalVariable.BrowserType + ">");
}
New:
public static void LaunchBrowser(string url)
{
CloseAllBrowsers();
BrowserWindow.CurrentBrowser = GlobalVariable.BrowserType;
GlobalVariable.browser = BrowserWindow.Launch(new Uri(url));
GlobalVariable.browser.Maximized = true;
if (BrowserWindow.CurrentBrowser == "Firefox")
{
Mouse.Click(_fireFoxAuthOK);
}
Logging.WriteLog("Browser was navigated to " + url + " in browser: <" + GlobalVariable.BrowserType + ">");
}

I think the problem is in this line :
Playback.PlaybackSettings.WaitForReadyLevel = Microsoft.VisualStudio.TestTools.UITest.Extension.WaitForReadyLevel.UIThreadOnly;
Because the browser's foreground thread is not ready to start the playback. you may try this
Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.Disabled;
or different alternative ways in your pc.
Refer this link Mathew Aniyan's Blog for further information.

Related

Selenium RemoteWebDriver() ERR_BLOCKED_BY_CLIENT on Chrome Extension in Selenium Grid, while without ChromeExtension works fine

We are using an extension in chrome for wiremock.
This chrome extension works beautifully while running locally both on Windows ( ref. 1), Mac computers.
However when instantiating RemoteWebDriver() in a Selenium Test Grid flavor named Moon, loading the extension fails (on Linux) catastrophically with ERR_BLOCKED_BY_CLIENT when trying to load the chrome extension.
(ref. 1)
On Windows localhost , execution actually fails with a message "That unpacked extensions is disabled by the admin"" but this can be easily workarounded by manually deleting a key at :
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallBlacklist
https://support.leapwork.com/hc/en-us/articles/360003031952-How-to-resolve-Error-Loading-of-unpacked-extensions-is-disabled-by-the-administrator
**- So I guess one needs to do something similar in the Test Grid node running Linux, but how does that code look like exactly? **
We have a switch statement in the code, so we see that code works generally fine in the test grid when tests are instantiated without the chrome extension.
Junit4.x
com.github.tomakehurst wiremock-jre8 2.32.0
jdk8 (we have so many indirect dependencies on about 77 or so different artifact versions so updating is almost impossible. (I suspect I will get the Nobel price in physics before that happens)
Chrome version 91.0.4472 is instantiated in the grid.
Error message :
idgpnmonknjnojddfkpgkljpfnnfcklj is blocked. This page has been blocked by Chrome. ERR_BLOCKED_BY_CLIENT”
We have tried a few different code constructs which all failed to unblock the extension from loading.
Here is one such code example we unsuccessfully tried with:
private RemoteWebDriver createDriver( Scenario scenario) {
RemoteWebDriver driver = null;
ChromeOptions options = mock ?
new ChromeOptions()
.addExtensions(new File("src/test/resources/modheader/idgpnmonknjnojddfkpgkljpfnnfcklj.crx")) :
new ChromeOptions();
options.setPageLoadStrategy(PageLoadStrategy.EAGER);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
Proxy proxy = new Proxy();
proxy.setHttpProxy("http://proxy.aaaaaaaaaaaaaaaa.com:8080");
proxy.setSslProxy("http:// proxy.aaaaaaaaaaaaaaaa.com:8080");");
proxy.setNoProxy("");
capabilities.setCapability("proxy", proxy);
capabilities.setCapability("enableVNC", true);
capabilities.setCapability("name", String.format("TEST - %s", scenario.getName()));
System.setProperty("selenide.remote","https://grid.aaaaaaaaaaaaaaaa.com/wd/hub");
System.setProperty("selenide.browser", "chrome");
System.setProperty("selenide.proxyHost", "proxy.aaaaaaaaaaaaaaaa.com ");
System.setProperty("selenide.proxyPort", "8080");
System.setProperty("selenide.proxyEnabled", "true");
if (System.getProperty("debugMoon") != null && System.getProperty("debugMoon").length()>0) {
capabilities.setCapability("devtools", true);
capabilities.setCapability("noExit", true);
System.setProperty("devtools", "true");
System.setProperty("noExit", "true");
System.setProperty("moon_debugged", "true");
}
// options.merge(capabilities);
try {
if(mock) { addHeaderMock(); } // adding header before Chromedriver new () when started in the MOON test Grid
logger.info("*********** Grid ***********");
final URL url = new URL("https://grid.aaaaaaaaaaaaaaaa.com/wd/hub");
logger.info(">>> Connecting to Moon test grid url: " + url.toString());
driver = new RemoteWebDriver(url, capabilities) ); // have tried both capabilities object but also options.merge(capabilities) with no joy
} catch (final Exception e) {
logger.info("Unable to create driver " + e);
}
logger.info("Connection established\n");
return driver;
}
Any hints or pointers in the right direction are much appreciated!

Svelte/Sapper - Encountered a build related bug with Luxon & Lodash

So I've just rolled out a new page (dashboard.svelte) on my prototype booking management app - I committed it along with a bunch of other changes and deployed to my Bitnami Node.js (Ubuntu 16.04) VPS.
Builds fine, but when loading any of the site in the browser, I get a bizarre error in the console which breaks execution of all other JS.
TypeError: Kn is not a function which ties back to the return Kn(t... section of a file called map.xxx.js:
var Kn, Xn = function (t, e) {
return function (n, r) {
if (null == n) return n;
if (!qe(n)) return t(n, r);
for (var i = n.length, o = e ? i : - 1, a = Object(n); (e ? o-- : ++o < i) && !1 !== r(a[o], o, a); );
return n
}
}(function (t, e) {
return t && Qn(t, e, Pe)
}); var tr = function (t, e) {
var n = - 1,
r = qe(t) ? Array(t.length) : [
];
return Kn(t, function (t, i, o) {
r[++n] = e(t, i, o)
}),
r
};
I spent several hours trying to track down the source of this bug (which to be honest is not very intuitive), and through trial and error tied it back to the aforementioned dashboard.svelte file (which works fine in npm run dev by the way)
https://gist.github.com/Bandit/58500ebc473e7d8d84bfb6ae16d41ea6
I've put all the information I can find about this in the above gist. I really hope someone can shed some light on the issue because I've had to rollback to an earlier commit for now.
FWIW I use DateTime via Luxon and several lodash methods elsewhere in the application without any issues, so it's not like this is the first time these packages have been built.
/EDIT1 Should note that if I rm src/routes/dashboard.svelte then npm run build everything works fine, so it's completely constrained to that one file...
/EDIT2 Commenting out the following lines in dashboard.svelte makes everything work fine:
// import merge from 'lodash/merge';
// const { session } = stores();
// $session.prefs = merge({}, $session.prefs);
But this makes no sense to me because this EXACT code exists in another page within my app:
import merge from 'lodash/merge';
import { onMount } from 'svelte';
import { hideAll } from 'tippy.js';
import { numberWithOrdinal } from './_helpers.js';
import { hasRole } from 'user.js';
const { session } = stores();
$session.prefs = merge({}, $session.prefs);
So it's something to do with the order of the imports?
/EDIT3 Regarding my comment below with the callstack, this is the line that triggers the issue (which is in a totally different file to dashboard.svelte and runs fine on the server):
$: if (dates && availableItems && availableBookings) populateGrid();
/EDIT4 So after extensive debugging we managed to pin it down to lodash.sortBy. Not sure why that is suddenly an issue as I've been using it for weeks without problem on another page within the app. Anyway I've removed all traces of it for now and all is well. For now (because I don't believe that is truly the issue)...
It's harder to debug because the JavaScript has been uglified.
In your rollup.config.js disable the terser plugin. (You can just comment it out)
Then re-run your build and it should give you non-mangled naming.
Another debugging tip is to edit the JS file map.xyz.js and add a debugger statement right before the line causing the error. Then re-run with devtools open. It will stop at that line and display the call stack. Look thru the call stack, it may shed light on where it's coming from.

Why Help.ShowHelp(chmFileName); not working in mono on linux?

Here I am trying to run .chm file when help is requested either using F1 key using Form1_HelpRequested(object sender, HelpEventArgs hlpevent) Why Help.ShowHelp(chmFileName); not working in mono on linux ? Where as it works good on visual studio, windows. Please help me to execute help on mono.
Maybe the relevant API calls aren't implemented on Linux.
private void ShowHelpForLinux()
{
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = "chmsee";
startInfo.Arguments = " " + help.chm + "::" + #"rootname//destination.htm";
Process.Start(startInfo);
}
For mono c# help, this code will work.
By Samdoss

JsTestDriver firefox browser crash

I'm just starting out with JsTestDriver and I've created very simple demo code to see if I have configured my environment correctly. However about 40-50% of the time I'm getting the following error when Firefox is launched (via JsTestDriver) "Firefox Closed Unexpectedly While Starting".
This error does not occur if I use Chrome.
My environment consists of:
VirtualBox 4.1.18 running Ubuntu 10.04.4 LTS 32bit
Firefox 13.0.1
JsTestDriver-1.3.4.b
openjdk-6-jre-headless
I'm executing:
java -jar /home/developer/bin/JsTestDriver.jar --port 9876 --browser /usr/bin/firefox --tests all --testOutput results
My JsTestDriver config is:
server: http://localhost:9876
load:
- src/*.js
test:
- test/*.js
timeout: 10
The source code (code under test) is:
Person = function()
{
this.firstName = "";
this.lastName = "";
this.fullName = function()
{
if((this.firstName != "") && (this.lastName != ""))
{
return this.lastName + ", " + this.firstName;
}
var name = this.firstName + " " + this.lastName;
return name.trim();
}
};
The test code (JsTestDriver based code) is:
PersonTest = TestCase("PersonTest");
PersonTest.prototype.testFullName = function()
{
fixture = new Person();
fixture.firstName = "John";
fixture.lastName = "Doe";
assertEquals("Doe, John", fixture.fullName());
};
PersonTest.prototype.testFullName_FirstNameOnly = function()
{
fixture = new Person();
fixture.firstName = "John";
assertEquals("John", fixture.fullName());
};
PersonTest.prototype.testFullName_LastNameOnly = function()
{
fixture = new Person();
fixture.lastName = "Doe"
assertEquals("Doe", fixture.fullName());
};
Thanks!
Your problem may be in that you're spinning up your server opening your browser every time you run your tests. I think a less error prone solution would be to start your server and have it capture some browsers, and then leave it running. Then you can run your tests against that server as needed. Our solution at work involves three virtual machines running IE7,IE8,IE9,Firefox, and Chrome all the time, and our Maven build process runs our javascript unit tests at every build. Also, make sure that you always use the '--reset' argument as well. It will keep your browsers fresh. I wrote a post that shows how to integrate QUnit, Requirejs, and code coverage with JSTD that is independent of Maven: js-test-driver+qunit+coverage+requirejs. Hope it helps.

unable to open sqlite3 database in QT

I am in the beginning phase of both sqlite, as well as QT.
There are various examples under QtSDK IDE for sqlite database. This is an excerpt from one of the examples :
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(":memory:");
if (!db.open()) {
QMessageBox::critical(0, qApp->tr("Cannot open database"),
qApp->tr("Unable to establish a database connection.\n"
"This example needs SQLite support. Please read "
"the Qt SQL driver documentation for information how "
"to build it.\n\n"
"Click Cancel to exit."), QMessageBox::Cancel);
return false;
}
This works just fine. but if I try to replace ":memory:" with an actual sqlite3 database file,...
void MainWindow::on_pushButton_5_clicked()
{
QSqlQuery query;
accounts_db = new QSqlDatabase();
*accounts_db = QSqlDatabase::addDatabase("QSQLITE"); perror("");
accounts_db->setDatabaseName("/home/aditya/test.db.sqlite");
QSqlError *a = new QSqlError();
*a = accounts_db->lastError();
perror(a->text().toLatin1());
if (!accounts_db->open()) {
perror("database open error :");
QMessageBox::critical(0,qApp->tr("db.open\n"),a->text(),QMessageBox::Cancel);
goto end; // quit if not successful
}
if ( !accounts_db->isOpen() ) {
perror("database is not open");
}
query.exec("select accno,branchcode,fname,lname,curbalance,accdate from accounts");
while(query.next()) {
QString str = query.value(0).toString();
std::cerr << qPrintable(str) << std::endl;
}
end:
;
}
...then I am not so lucky. Not sure exactly how lastError() works, but tried it anyway. I am getting these errors...
No such file or directory
: Invalid argument
QSqlQuery::exec: database not open
I have tried changing the permissions n'all on the concerned files and folders as suggested on different forums, but to no results. Just a note, I am working on Ubuntu Linux (...if that matters), I have also tested this test.db database file with the sqlite3 command line program, that works flawless.
Any guidance is appreciated...thanks.
EDIT:
Very sorry that I completely forgot to explain what the error is... :|
Created a brand new database, and it works !!!
not clear why it was not working before though... I definitely need to study more.
Anyway, thanks a lot ppl :) .

Resources