CodedUI Keyboard.SendKeys() not working with Special character - coded-ui-tests

I am inserting value to a Windows security Form. However while using Keyboard.SendKeys() with some special character it opens Server Explorer.
Piece of code i am running.
WinWindow securityWindow = new WinWindow();
securityWindow.SearchProperties[WinWindow.PropertyNames.Name] = "Windows Security";
WinEdit username = new WinEdit(securityWindow);
username.SearchProperties[WinEdit.PropertyNames.Name] = "User name";
WinEdit password = new WinEdit(securityWindow);
password.SearchProperties[WinEdit.PropertyNames.Name] = "Password";
Keyboard.SendKeys(username,"Admin");
Mouse.Click(password);
Keyboard.SendKeys("Winter#123");
I am working on a Windows Server machine and When script tries to Enter Winter#123 to textbox, it enters upto Winter#1 and then opens Server Explorer. Hence Login got failed.

Try with Keyboard.SendKeys("Winter{#}123");

Try using Sendkeys.SendWait. It would wait for a fraction of second before entering the next character

Related

How to add shortcut link in "Quick Access" in Windows 10 through code?

I want to add shortcut link of one of the folder location to "Quick Access" in windows 10.
In the case of Windows 7 & Windows 8, I used to put my shortcut link in the folder "C:\Users\user_name\Links" & it showed me shortcut in favorites at left side. So I want to do same thing for Windows 10.
I directly copy shortcut & pasted into the location of Quick Access. But still it's not showing in left panel of Quick Access.
As i know there are two option in Quick Access : 1. Frequent Folders & 2. Frequent Files.
So at what location do I need to put that shortcut link so it will appear in Quick Access section in left panel ?
And also I wanted to ask, how "OneDrive" link they have added in left panel in Windows 10 ? So is there any registry entry or any specific location ?
You can do it via this powershell script:
$o = new-object -com shell.application
$o.Namespace('c:\Folder').Self.InvokeVerb("pintohome")
I didn't found proper solution.
But I applied workaround for my problem.
I created folder at Quick Access location (\Links). And using mkilink cmd I changed the symbolic link of it to target folder. I used mklink using cmd prompt in C# code using Process.
I am using following code to create folder shortcut at c:\users\user_name\links and it is working fine in windows 7 & 8 but can't see it under windows 10 quick access link in windows explorer.
string sLinkFileName = "c:\users\user_name\links\\" + DefineString.AppName + ".lnk";
FileInfo objfiLinkFile = new FileInfo(sLinkFileName);
if (objfiLinkFile.Exists)
{
try
{
objfiLinkFile.Delete();
}
catch (Exception ex)
{
Logger.Log(LoggingLevel.Info, MethodBase.GetCurrentMethod().Name, string.Empty, ex);
}
}
//Place a shortcut to the file in the special folder
objfiLinkFile.Refresh();
if (objfiLinkFile.Exists)
{
Logger.Log(LoggingLevel.Info, MethodBase.GetCurrentMethod().Name, "Old link file still exists.");
}
// Create a shortcut in the special folder for the file
// Making use of the Windows Scripting Host
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
IWshRuntimeLibrary.IWshShortcut link = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(objfiLinkFile.FullName);
link.TargetPath = Utils.msApplicationRootPath;
link.WindowStyle = 1;
link.Description = string.Format(DefineString.m00025, DefineString.AppName);
link.IconLocation = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\RootFolder.ico";
link.Save();
I also tried to call mklink as you mentioned; but it didn't work. Unfortunately we don't have any direct control over user desktop. mklink command requires admin privileges? Which mklink command you used to fix the issue. Your help will be greatly appreciated.
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = string.Format(#"/C mklink {0} {1}", sLinkFileName, Utils.msApplicationRootPath);
process.StartInfo = startInfo;
process.Start();

Delay the opening of other tabs, until the first tab loads completely

I am creating a Chrome Extension, using JS that takes a user prompted URL parses some variables out of it, and then loads multiple tabs based on the information that was parsed. The issue, is that before I can do that, I need to wait for a login tab to complete loading, before trying to open the other tabs. So the preferred order would be
User Prompt
Load Login Tab
Wait until Login Tab is loaded
Open remaining tabs.
My code is as below
var URL_Proper = prompt ('Paste the Become-User-ID URL below:');
var User_ID = URL_Proper.substring(URL_Proper.indexOf('?become_user_id=')+16,URL_Proper.length);
var Domain = 'https://' + URL_Proper.substring(8,URL_Proper.substring(8,URL_Proper.length).indexOf('/')+8);
var win = window.open(Domain + 'login_key', '_blank');
var win = window.open(URL_Proper, '_blank');
var win = window.open(URL_Proper.substring(0,URL_Proper.indexOf('?')), '_blank');
var win = window.open(Domain.substring(0)+'/users/'+User_ID, '_blank');
The delay I would like would be between the (Domain + 'login_key', '_blank'); and the other three tabs, but I can't for the life of me figure it out. My guess is this would be better served with chrome.tabs.create, but I am such a beginner that I can't figure out how to do that, nor can I figure out how to make the code wait for the first tab to load, before opening all the other tabs.
Thank you.

AutoIt v3: _IENavigate + _IELoadWait Not Working as Expected?

This code is supposed to open a new browser set at "www.website.com," submit a username and password, wait for the page to load after being submitted, navigate to a new page, and inject a javascript code into the address bar.
My current results from this code are opening a new browser set at "www.website.com," submit a username and password. The submit works, then from here, the code breaks and instead of navigating to the next page (page2) it just hangs.
Even when I add an ignore command to the _IEFormSubmit($oForm) I can't get my page to navigate to the next page.
#include <IE.au3>
#RequireAdmin
Local $oIE = _IECreate("http://www.website.com")
;_IELinkClickByText($oIE, "Sign In") ;Optional
Local $oForm = _IEFormGetObjByName($oIE, "regular-user-login-form")
Local $oText = _IEFormElementGetObjByName($oForm, "log")
_IEFormElementSetValue($oText, "username")
Local $oText = _IEFormElementGetObjByName($oForm, "pwd")
_IEFormElementSetValue($oText, "password")
_IEFormSubmit($oForm)
_IENavigate($oIE, "http://www.website.com/page2/")
Send("{F4}javascript:check_in();{ENTER}")
Please for the love of god, what am I doing wrong.
Edit: I've also changed the _IEFormSubmit($oForm) to another javascript submit and I can still log in without any problems, but once I reach that next page I can't use _IENavigate, so the problem has to lie there.
I have automated so many different pages and sometimes the script gets stuck on _IEFormSubmit for no reason. That's an AutoIt bug.
Her's a quick fix for that
_IEFormSubmit($oForm, 0)
_IELoadWait($oIE, 1000)
Your code should be:
#include <IE.au3>
#RequireAdmin
Local $oIE = _IECreate("http://www.website.com")
;_IELinkClickByText($oIE, "Sign In") ;Optional
Local $oForm = _IEFormGetObjByName($oIE, "regular-user-login-form")
Local $oText = _IEFormElementGetObjByName($oForm, "log")
_IEFormElementSetValue($oText, "username")
Local $oText = _IEFormElementGetObjByName($oForm, "pwd")
_IEFormElementSetValue($oText, "password")
_IEFormSubmit($oForm, 0)
_IELoadWait($oIE, 1000)
_IENavigate($oIE, "http://www.website.com/page2/")
Send("{F4}javascript:check_in();{ENTER}")
Onetime, I tried to report two bugs to autoit forum, but the guys who are there are pretty frustrated fellas. So, now when I find one, I just solve it my way.
Off topic:
When dealing with objects you should know of another bug
If $oInput.outertext = "Continue" then ...
The above code will sometime fail even if the outertext matches.
This is solved using, use
If $oInput.outertext == "Continue" then ...

Release File behaviour

Hi i have an RFID application in c#. I am experiencing a strange behavior when i get the .exe from the Release folder
My application connects to a serial RFID reader and checks the connection status :
bool serialConnect = false;
string inventoryNum = "";
string sendMsg = "";
string recvMsg = "";
StringBuilder sb = new StringBuilder();
serialConnect = rfidCard.connectSerial(); //Connect Serial method changes status to true if cable is connected and right port is selected
if (serialConnect == false)
{
//MessageBox.Show("Card read failed.");
MessageBox.Show(" RFID reader's serial cable is not connected or the wrong port is selected !! Check the cable connection and try again or for port settings check Device Manager --> Port ");
return;
}
It works fine when i run it from inside Visual Studio . But when i extract the .exe and test it on a different machine the false condition is always getting executed and then on clicking the "Load" button again the application behaves normally
So even if the correct COM port is selected , the application will still execute the false message and then will just display the result again if "Load" button is clicked.
To resolve that I tried to make a practice of clicking on "Connect COM port" always but still does not work
I tried rebuilding the release folder and tried to import all the files to find if I am probably not importing a dependency in the folder , but still it behaves the same . The application keeps behaving normally unless it is exited and a new one is opened . Any suggestions as to why its behaving weirdly ?

Flex - how to download a string variable as a file to the local machine?

I have a String variable in my flex (flash builder 4) application containing CSV data. I need to allow the user to download this data to a local file. For example, giving them a "csv" button to click and it might present them with a save file dialog (and I would be sending the contents of my string variable).
Is this possible / how ?
I am using the ResuableFX component for the datagrid to csv. This the code I ended up with that works to save the string to a text file for the user (in a web browser):
var dg2CSV:DataGrid2CSV = new DataGrid2CSV();
dg2CSV.includeHeader=true;
dg2CSV.target=adgEncounters;
var csvText:String=dg2CSV.getCSV();
var MyFile:FileReference = new FileReference();
var csvFileNameDT:String = QuickDateFormatter.format(new Date().toString(),"YYYYMMDDJJNNSS");
MyFile.save(csvText,"Encounters"+csvFileNameDT+".csv");
If you're in an AIR App you can use File.browseForSave().
If you're in a web app, you can use FileReference.save() . The FileReference docs have a lot more info on this.
In many cases, I would recommend using navigateToURL() to open the file outside of Flash and let the browser deal with it.
I'm not sure if there is a way to do this without user interaction.

Resources