when testing the webUI, when uploading a file through button,but when use input element, but it is ugly, If you have some ideas not replace button to handle uploading file.
Selenium 2 library provides "Choose File" keyword to upload the file. It takes two arguments, first is locator for the button and second is path to the file which needs to be uploaded.
Example: choose file xpath=.//div/input ${TEMPDIR}${/}file_pa.csv
Reference: http://robotframework.org/Selenium2Library/Selenium2Library.html#Choose%20File
I had the same issue and I was able to solve it using other libraries. Selenium2Library support "Input" field, so it only works when you have an input field to select the field then click other button to make the upload. Which is an old fashioned scenario. In order to achieve this you need other libraries that control the windows control like AutoItLibrary or SikuliLibrary Below is a quick example using either ways
AutoItLibrary:
sleep 2s
Send ${ImagePath} # This sends the file path to the entery field where the cursor is focused
sleep 3s
Control Click strTitle=Open, strText=Open, strControl=1, strButton=Button1, nNumClicks=1, nX=1228, nY=291
# In some cases some parameters cannot be identified easily so yo might just use only the buttong name as the following
# Control Click ${EMPTY} ${EMPTY} Button1 ${EMPTY} 1
For SikuliLibrary you can use the Press key to click the controllers and you can find many ways to emulate the copy paste either using javascripts or other key words. For the enter emulation on SikuliLibrary use the following:
Press Special Key ENTER #Case senstive (to press enter with Sikuli)
Related
I'm using the Sikuli Library with Robot Framework to run tests for a local windows application. Most solutions online are selenium based but I believe that only to work for web applications.
Entering text has been fine for the empty fields when there isn't a default value concerned.
Currently, I'm dealing with a field that contains a default value of 5000 but I need to change it to 10.
Text Field:
So far I've tried things such as:
Double-clicking the field first to highlight then type over (Input Text single clicks and removes highlight anyway)
Single-Clicking as Input text single clicks itself (Does not happen fast enough to simulate a double click)
I will answer in Sikuli terms. You just execute Ctrl+a to select content of the cell and then type 10
type('a', KeyModifier.CTRL)
type('10)
I am using Firebase Robo script test now.
I found out the robo script would failed because robo script recorded the
text of button I clicked instead of the resource id.
When I want to i18n test, it would failed in other language.
Anyway to prevent this ?
By default the recorded Robo script will contain ids, text and contentDescriptions of elements. When this script gets used all specified fields need to match. There are 2 ways around this:
a) Manually remove the elementDescriptors fields from the script that you don't want to be used for matching.
b) There's an option in Android Studio that allows you to disable the recording of text and contentDescription fields. Go to File -> Settings -> Build, Execution, Deployment -> Espresso Test Recorder and uncheck both "Use text for element matching" and "Use content description for element matching". Afterwards re-record the Robo script. It should no longer contain text and contentDescription fields in the elementDescriptors array.
I need to be able to click an element on a webpage and hold the Shift key on keyboard and press another element.
Can I implement this behaviour using "Press Key" in Selenium2Library?
You can try to achieve your scenario using AutoItLibrary
First you need to install win32com.client, use below command
pip install pypiwin32
Then use AutoItLibrary command like as per your requirement
Send | {SHIFTDOWN}
For more info visit here
Use using Pyautogui library. This library simulates the User Actions on GUI such as Mouse Control, Keyboards inputs,etc. You can find details at
https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjN1ZbrocrSAhWIFJQKHXbiBGcQFggbMAA&url=https%3A%2F%2Fpyautogui.readthedocs.io%2F&usg=AFQjCNEe5LY5eMdaquVD421_u-mpoFUOYQ&sig2=Lj-e4YldvbLNEvPe4NFHrA
Also U can install this library using pip by following keywords in following docs
http://pyautogui.readthedocs.io/en/latest/install.html
I have a problem with Inno Setup DefaultDirName. My code looks like this:
#define MyAppName "My Program"
#define MyAppVersion "1.0"
#define MyAppPublisher "My site"
#define MyAppURL "mysite.net"
#define MyAppExeName "My Program.exe"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{36D5C912-2F45-4295-956F-53E668BD6094}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName=c:\Please Choose the Path to Your Program
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
LicenseFile=D:\My Program\EULA.txt
OutputDir=D:\My Program\Inno\
OutputBaseFilename=setup
SetupIconFile=D:\My Program\\Graphics\Icon.ico
Compression=lzma
SolidCompression=yes
Everything works like I want it to except one thing. My program is made to modify a couple of different softwares. That's why I can't specify one default directory for all of them. At the same time I want to clearly point out what directory user is suppose to choose. That's why I wrote it like this:
DefaultDirName=c:\Please Choose the Path to Your Program
The problem with that line of code is that when user points to certain directory my installer is trying to add "\Please Choose the Path to Your Program" to that directory (which will obviously cause my program to not work properly). How can I prevent this from happening but still let the user know what directory is he suppose to choose when instaling my program?
Set the AppendDefaultDirName directive to no, e.g.:
[Setup]
...
AppendDefaultDirName=no
As the reference says (emphasized by me):
By default, when a folder in the dialog displayed by the Browse...
button on the Select Destination Location wizard page is clicked,
Setup automatically appends the last component of DefaultDirName onto
the new path.
For example, if DefaultDirName is {pf}\My Program and "Z:\" is clicked, the new path will become "Z:\My Program".
Setting this directive to no disables the aforementioned behavior. In
addition, it causes a Make New Folder button to appear on the dialog.
(1) For example, I want to set map gd g* in Qt's Fakevim like below but failed.
(2) And also I'd like to set F3 as the save command, how to do it?
(3) In Fakevim, it provides an option "Read .vimrc", but where to find the file .vimrc?
Thank you!
It doesn't look like there is a lot of documentation for FakeVim, so official sources might not exist. Most of this was obtained by experimentation.
If you want to dig deeper, I guess there's no source as official as the actual source: http://qt.gitorious.org/qt-creator/qt-creator/blobs/0809986e501415fe2c8508800b94b5b3169dc048/src/plugins/fakevim/fakevimplugin.cpp
User commands
First off, realize that in Tools>Options>FakeVim>User Command Mapping, you're only setting what your user actions will perform, not how you perform them.
By default, user command #1 is triggered by pressing Alt-V, then 1.
Alt-V, then 2, triggers user action #2, and so on.
You can change the keyboard shortcuts through the general QtCreator configuration interface, under Tools>Options>Environment>Keyboard. There is a "FakeVim" section with all the user actions listed. Select your user action of choice, press the little "erase" icon in the input field under "Shortcut", then press your desired shortcut key, which should appear in the input field.
Second, to finish a command where you would normally press enter, you should literally type in <CR> after the commands. You also need to enter in ':' to enter command mode.
So if you wanted to map the vim save command, ":w", to F3 via FakeVim, you would:
Go to Tools>Options>FakeVim>User Command Mapping.
Enter ":w<CR>" as one of the user commands (say #7).
Go to Tools>Options>Environment>Keyboard.
Find the FakeVim action "UserAction7".
Set F3 as a shortcut for it.
Now, every time you're in the editor, you should be able to click F3 and have the FakeVim :w command execute, which will save your file.
Note that there is also an option to set a shortcut for "Save" directly in the QtCreator keyboard settings, so for this particular shortcut you don't actually need to go through FakeVim.
Setting shortcuts for other vim commands should be similar. Note that you're restricted to the subset of vim commands that FakeVim implements. Refer to the source, linked above, for checking any particular command you're wondering about.
Vimrc file
On Linux this would be ~/.vimrc, a file in the user's home directory. I presume you're asking about Windows.
The best source I can find is this bug report about it being hard to use Fakevim's vimrc on Windows: https://bugreports.qt.io/browse/QTCREATORBUG-8748
Following that, the file Fakevim looks for is ".vimrc" in %USERPROFILE% (you can enter a name like that in Explorer to go to the folder). However, it's tricky to access a file with a name like that on Windows. (Thus why the real vim uses '_vimrc' on Windows -- but FakeVim apparently doesn't, at least at the moment.)
Here is a superuser page with workarounds for how to create such files on Windows: https://superuser.com/questions/64471/create-rename-a-file-folder-that-begins-with-a-dot-in-windows