We are provided with gherkins and asked to create feature files and perform automation testing when only UI prototypes are available and there is no URL provided. Is there a way to perform testing when there is no url available?
You can "write" tests when there is no URL available by using the Gherkin format. Here's an example for some calculator tests:
Feature: Scenarios for the Calculator App
Background:
Given Open the Calculator App
Scenario: Pressing "C" outputs "0"
When Press C
Then Verify output is "0"
Scenario: 1 + 2 + 3 + 4 + 5 = 15
When Press C
And Press 1
And Press +
And Press 2
And Press +
And Press 3
And Press +
And Press 4
And Press +
And Press 5
And Press =
Then Verify output is "15"
Scenario: 6 × 7 × 8 × 9 = 3024
When Press C
And Press 6
And Press ×
And Press 7
And Press ×
And Press 8
And Press ×
And Press 9
And Press =
Then Verify output is "3024"
(The above examples of a Gherkin feature file were taken from the SeleniumBase Behave-BDD examples folder, which I wrote. It requires a steps file with definitions in order to work.)
Related
I am writing a script to print a section of a bookdown online book as PDF, then move to the next section, and so on.
The print part works (the key codes are from this page):
tell application "Safari"
activate
tell application "System Events"
key code 35 using command down -- activate print menu item
end tell
delay 0.5
set i to 0
repeat while i < 15
set i to i + 1
delay 0.1
tell application "System Events"
key code 48 -- press tab 15 times
end tell
end repeat
tell application "System Events"
key code 49 -- press space
end tell
set i to 0
repeat while i < 2
set i to i + 1
delay 0.1
tell application "System Events"
key code 125 -- press down key twice
end tell
end repeat
tell application "System Events"
key code 36 -- enter
end tell
set i to 0
repeat while i < 16
set i to i + 1
delay 0.1
tell application "System Events"
key code 125 -- press tab to get to "save"
end tell
end repeat
tell application "System Events"
key code 36 -- enter to cleck on save
end tell
end tell
Problem
Now that I have printed the current section and I am back on Safari, I can click manually on the right arrow and move to the next section, but I can't manage to have the script to do that.
I have tried to add the following to the script above:
tell application "System Events"
key code 124 -- right arrow to enter the next page
end tell
Or even to "reopen" Safari, but nothing happens.
tell application "Safari"
activate
tell application "System Events"
key code 124 -- right arrow to move to the next section
end tell
end tell
How can I have AppleScript "turn the page" and move to the next section?
Also, I welcome suggestions to improve the script! I wonder if it would be easy to avoid repeating "tab" 15 times. I have looked at the Accessibility Inspector and found that "PDF" in the print menu corresponds to NSPopUpButtonCell. I have tried to use select NSPopUpButtonCell of its sheet but it did not work.
I can click manually on the right arrow and move to the next section, but I can't manage to have the script to do that.
How can I have AppleScript "turn the page" and move to the next section?
If you are trying to programmatically click the right-arrow, as shown in the image below, then the following example AppleScript code can do that:
tell application "Safari" to ¬
tell document 1 to ¬
do JavaScript ¬
"document.getElementsByClassName('fa fa-angle-right')[0].click();"
Notes:
This requires Allow JavaScript from Apple Events to be check on the hidden Develop menu.
To unhide the hidden Develop menu:
Safari > Preferences… > Advanced > [√] Show Develop menu in menu bar
Update to address:
Also, I welcome suggestions to improve the script! I wonder if it would be easy to avoid repeating "tab" 15 times.
Here is how I'd use the JavaScript from above and coded to avoid using the key code and or keystroke System Events commands, especially tabbing around the UI.
Example AppleScript code:
tell application "System Events"
tell application process "Safari"
set frontmost to true
set i to 0
repeat until (its frontmost = true)
delay 0.1
set i to i + 1
if i ≥ 20 then return
end repeat
click menu item "Print…" of ¬
menu 1 of ¬
menu bar item "File" of ¬
menu bar 1
tell its front window
set i to 0
repeat until (exists menu button "PDF" of sheet 1)
delay 0.1
set i to i + 1
if i ≥ 20 then return
end repeat
click menu button "PDF" of sheet 1
set i to 0
repeat until (exists menu item "Save as PDF" of ¬
menu 1 of menu button "PDF" of sheet 1)
delay 0.1
set i to i + 1
if i ≥ 20 then return
end repeat
click menu item "Save as PDF" of ¬
menu 1 of ¬
menu button "PDF" of ¬
sheet 1
set i to 0
repeat until (exists button "Save" of sheet 1 of sheet 1)
delay 0.1
set i to i + 1
if i ≥ 20 then return
end repeat
click button "Save" of sheet 1 of sheet 1
set i to 0
repeat while (exists sheet 1)
delay 0.1
set i to i + 1
if i ≥ 100 then return
end repeat
end tell
end tell
end tell
tell application "Safari" to ¬
tell document 1 to ¬
do JavaScript ¬
"document.getElementsByClassName('fa fa-angle-right')[0].click();"
Notes:
Since this type of AppleScript script is using UI Scripting, I have included an error handling in the form of a repeat loop to wait up to two seconds for the target UI element to become available to be acted upon for most of the targets, however the last repeat loop waits longer because it has to wait until the Save as PDF to complete. A simple delay command with an appropriate value could be used instead, but with the include delay of a tenth of a second in the repeat loops it shouldn't have to wait any longer than need be. In other words, I'd only use simple delay command if I want to slow the script down from going through the various events of the UI. It's doubtful that it would need to be adjusted, but obviously do so as/if necessary.
If the timeout is reached, the script aborts at that point without any error message. The single-line if i ≥ 20 then return statements can be turned into a full if block and include an error message via the display dialog, display alert, or display notification command as wanted.
For example, alt + cmd + v is shortcut for behavior split vertically, and alt + cmd + b is shortcut for go to implementation. Question is how do I merge these two actions split vertically and go to implementation into only one shortcut(say cmd + i)?
I managed to do what you need by following these steps;
cmd + shift + a(find in action) + type start macro recording
enter your commands consecutively (shortcuts). It will start recording every shortcut/keystrokes.
cmd + shift + a + type stop macro recording
enter a name for your macro (testmacro)
cmd + shift + a + type edit macros and select your recently created macro (testmacro)
The list should be as following;
Action: SplitVertically
Action: GotoDeclaration
update your macro by pressing ok
select or put your cursor on the variable/method/class that you want to go to the declaration and hit - cmd + shift + a + type testmacro and enter
Alternatively, it could be better to assign a shortcut to Play saved macros and then instead of typing a lot, you can select your macro from the list after hitting the shortcut of play saved macros.
Here are the screenshots of the process
My test case is to automate an application where orders will be generated. But the problem here is once the order is submitted a page will be loaded saying order no bla bla is generated. But this page loads max for 2 sec and it goes to next page. How to get the order number from this page.
Open the dev tool before performing the action that causes the desired window to appear.
Go to the Sources tab
Now perform the action that makes the window to appear.
When the window is visible press F8 or Ctrl + \ on the keyboard to pause script execution.
Now press Ctrl + Shift + C or select the Select element for inspection tool from the top left corner of the dev tool.
Now select the window and get the DOM for the window that hides very fast.
I want to have the 'Ctrl'+'K','Ctrl'+'D' functionality of Sublime in Android Studio, how do I do it?
Perfectly similar to this question, but with respect to Android Studio.
How do I skip a match when using Ctrl+D for multiple selections in Sublime Text 2?
I use Ctrl+D to add to selection (discrete multiple select) the next occurrence of the string (or substring) highlighted. And to skip adding next immediate selection to selection but the one after it, I use Ctrl+K, Ctrl+D. How do I do the same in Android Studio.
I just know Alt+J is similar to Ctrl+D (found from Keymappings in Android Studio).
And to deselect the last selected it's Alt+Shift+D.
But how do I skip next occurrence?
My question is in no way related to:
Does IntelliJ IDEA have a `Ctrl` + `K`, `Ctrl` + `D` equivalent?. That's Visual Studio equivalent. I want the SublimeText equivalent.
Check http://blog.jetbrains.com/idea/2014/03/intellij-idea-13-1-rc-introduces-sublime-text-style-multiple-selections/
Select next occurrence: Alt + J (Ctrl + G for Mac OS X)
Unselect next occurrence: Shift + Alt + J (Shift + Ctrl + G for Mac OS X)
Select all occurrences: Shift + Ctrl + Alt + J (Ctrl + Cmd + G for Mac OS X)
Remove all selections: Esc
Add/remove a selection: Alt + Shift + Mouse Click
It is described in this Issue that was initially created because this skip-next was missing.
Anyhow you just press F3 to skip next possible selection.
If you are using OSX, there are two answers, depending on what keymap you have selected in Preferences:
Keymap : Mac OS X 10.5+
To start / add to your discrete multiple selection : CTRL+G
To skip the current selection and move to the next : CMD+G
Keymap : Mac OS X
To start / add to your discrete multiple selection : CTRL+G
To skip the current selection and move to the next : F3
(this mode is really awkward IMO - no flow)
If you have more follow up questions I had success asking support via this thread : https://youtrack.jetbrains.com/issue/IDEA-121956
Go To Settings -> Keymap -> Main Menu -> Edit -> Find
OR Search for the following options in Settings -> Keymap
Set the shortcuts for the following (Linux/Mac) :
Add Selection for Next Occurrence : Ctrl + D/Cmd + D
Find Next/ Move to Next Occurrence : Ctrl + K/Cmd + K
You might also want to setup Unselect occurrence:
Unselect Occurrence : Ctrl + U/Cmd + U
Carefully remove/replace/override any other existing bindings with these shortcuts according to your needs. You should have Sublime Text Ctrl+D, K behaviour working.
Note: Test these shortcuts for functionality with the default key bindings first. This will ensure, you get working shortcuts with your favourite shortcut keys.
I needed to use sublime's Ctrl+D (switch between multiple selected).
The F3 key worked for me.
In a VB console application, how do you automatically put a string in the cursor? example:
ask for numbers
user inputs 5 15 five
show error
show back "5 15 five" back to the user so he can change five to 5 or any other integer.