Simulating user interaction in Dyalog APL - user-interface

I have a menu with a submenu and would like to simulate a user interaction where the user clicks on the menu and then on a submenu using ⎕NQ. However, I can only simulate one event; the subsequent ones are not handled unless I intervene by clicking manually somewhere with the mouse.
Here is an example:
CreateMenu
'f' ⎕WC 'Form' ('Caption' 'Menu Test')
'f.menuBar' ⎕WC 'MenuBar'
'f.menuBar.menu' ⎕WC 'Menu' '&One'
'f.menuBar.menu.miA' ⎕WC 'MenuItem' ('Caption' 'Choice A')
'f.menuBar.menu.miB' ⎕WC 'Menu' ('Caption' 'Choice B')
'f.menuBar.menu.miB.miX' ⎕WC 'MenuItem' ('Caption' 'Choice X')
'f.menuBar.menu.miB.miY' ⎕WC 'MenuItem' ('Caption' 'Choice Y')
And here are the events I have tried:
⎕NQ 'f.menuBar.menu' 'Select' ⋄ ⎕DL 0.5 ⋄ ⎕NQ 'f.menuBar.menu.miB' 'Select'
Any clues?
(Remark: in this particular example, if we wanted to simulate a click on, say, "Choice Y", it isn't actually necessary to first ⎕NQ "One" and "Choice B", but ideally, we'd like to see choices being made in the GUI as if an actual user made them.)

I asked John Daintree, the implementer and maintainer of ⎕WC, ⎕NQ etc. if it is possible to automate user interaction using ⎕NQ. His response was:
Not completely. You can do some things, but not everything. So it's not really viable as a way of testing [progressive selection from menus].
(…)
The next problem that you'll hit is that the interpreter won't process the next event (…), because the interpreter can't do anything while the menu is down.
Maybe have a look at Microsoft Power Automate or AutoHotKey instead?

Related

How to click a span in capybara tests?

I'm trying to click on a checkbox, but when I run the action, it doesn't work.
I'm using the same way to click buttons and other elements.
I'm using a data-testid to find the checkbox in the view.
I need to click on the checkbox, and after clicking execute the actions of the next step.
This checkbox is a react component that will have a span in the view.
context 'when the user agrees to charges by clicking a checkbox' do
before do
# sleep 1000
wait_before_clicking
page.find("span[data-testid='prepay-enrollment-modal-agreement-checkbox']").click
end
it 'renders new content for the user to review payment details' do
expect(page).to have_selector("[data-testid='review-step-container']")
expect(page).to have_content("Your Plan")
expect(page).to have_content("100 pages/ month")
expect(page).to have_content("Plan cost for 12 months, before discount")
expect(page).to have_content("Prepay discount (10%)")
expect(page).to have_content("Total Due:")
end
end
The data-testid attribute is on the input element not on the span, so find("span[data-testid='prepay-enrollment-modal-agreement-checkbox']") won't work. If you put the data-testid attribute on the span rather than the input then it would work, however there's a better way. Since the checkbox has an associated label element you can just tell Capybara it's allowed to click on the label element if necessary. First, since you're using test ids, set
Capybara.test_id = 'data-testid'
in your global config, and then in your test just do
page.check('prepay-enrollment-modal-agreement-checkbox', allow_label_click: true)
Note: rather than expect(page).to have_selector("[data-testid='review-step-container']") you should use expect(page).to have_css("[data-testid='review-step-container']") to make it clearer that you know you're passing CSS. Also for test speed reasons you may want to combine all of the have_content calls into one using a regex

multiple option texts are identified by Cypress

When i am passing on the below command .get('.mat-option-text') Cy is identifying even the options of the dropdowns which are not in focus. Due to this Cy is trying to click the options which are not even visible and tests are failing. Any help on this? I want to click the option which is currently in focus.
cy.contains('Test Options')
.click({force: true})
.get('.mat-option-text').and('be.visible')
.contains('NOT SURE')
.click({force: true})
I think that you are confusing the word focus with the element being viewable in the viewport.
If you want to select the focused option you can do it vía cy.focused(), more info
But I think that you are referring to being able to click on something that is not viewable in the dropdown. Here you can use scrollTo to navigate to some position of the dropdown if you know the position or the coordinates:
cy.contains('Test Options')
.click()
.scrollTo('bottom')
Or you can scroll into view given the element like this:
cy.contains('Test Options')
.click()
.get('.mat-option-text')
.contains('NOT SURE')
.scrollIntoView()
.click();
Hope that this helps

Check if an element with varying text casing is displayed in Appium and perform logic accordingly

I'm using Appium with the Cucumber Framework and utilizing the Ruby language.
My scenario is my app has multiple buttons that I want to call with a single Gherkin statement "I press the "*" button" where * is modular. I use it for Save, Back, Cancel, Expand, Yes, No, etc buttons with simple text. Here's an example:
And I press the "Create a Note" FAB button
And I am on the Create a Note Screen
Then I tap Back
>> And I press the "Yes" button
Now currently with my app on android there are multiple versions of the "Back" button and they're not all formatted the same. Some have texts that reads "BACK", some are "Back", and some are "back". I designed a series of if statements to handle this discrepancy until I can get the developers to standardize the text they use for these buttons:
Then(/^I press the "([^"]*)" button$/) do |button_text|
sleep 1
#button_text = button_text
binding.pry
if find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").displayed? == true
find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").click()
else
#button_text.capitalize()
if find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").displayed? == true
find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").click()
else
#button_text.upcase()
if find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").displayed? == true
find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").click()
else
#button_text.downcase()
if find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").displayed? == true
find_element(xpath: "//android.widget.Button[#text='#{#button_text}']").click()
else
fail("Could not find a permutation of that button")
end
end
end
end
sleep 2
end
My thinking is that I'll save the button_text argument to a variable, #button_text, and then use the .displayed? method to check if that version of the button is available. If it is I pass the .click() method, and if it isn't I alter the text of the variable via the .capitalize, .upcase, and .downcase methods. I'm sure that using nested if statements isn't the most ideal way to do this so I would love some assistance on a better way to write that statement.
The issues I receive is I get "An element could not be located using the given search parameters" error whenever I get to this line of code. It seems like the .displayed? method doesn't return a value and triggers appium to stop the test.
I want appium to check if that version of the button is present, then adjust the variable and check the new version for upcase, downcase, and capitalize. Any and all assistance would be greatly appreciated.
When you're finding the elements, try setting their text to all uppercase, and then checking for one version of the word that you're searching for.
I.e. BacK or back or BACK would all become "BACK"

How to handle windows pop up in IE using Ruby

Please help me how to handle this pop ups.
Based on your last question, I assume you are using Watir-Classic (even though you have also listed Watir-Webdriver).
As #orde mentioned in the comments, Watir has an Alert class for handling these types of dialogs. Unfortunately, in terms of clicking buttons, Watir-Classic only has an #ok method defined:
# Press the "OK" button on the JavaScript dialog.
def ok
dialog.button(:value => "OK").click
wait_until_not_exists
end
This will not work for this dialog as there is a "Yes" and "No" button rather than an "OK" button. You will need to duplicate this functionality with the right value.
Note that the dialog is a RAutomation window and no longer Watir specific code. As a result, the button values are not always intuitive - it is not always just the text you see. To get the right values, you should ask the dialog what values it sees:
browser.alert.send(:dialog).buttons.map(&:value)
#=> ["&Yes", "&No"]
We can then make the same calls as the #ok method, but with the correct value:
alert = browser.alert
alert.send(:dialog).button(:value => '&Yes').click
alert.wait_while_present
This code is working fine to handle this type of pop ups:
save_dialog = WIN32OLE.new("AutoItX3.Control") save_dialog.ControlClick("Windows Internet Explorer", "Yes", "[CLASS:Button;INSTANCE:1]")

Clicking a button with WATIR WebDriver

I have been struggling with this all morning and was hoping to get some assistance.
I have this button on a webpage that pulls up a control panel that lets the user select which widgets to display. I'm trying to get this to fire using watir webdriver and firefox 9.0 but having no luck at all. I'm able to login to the site, get to the page that contains the button but just can't click the 'CHOOSE YOUR FEATURES' button.
<div class="personalizationButton">
<span class="personalizationStatus"></span>
<b class="widgetPanelLink neo-button button-white">
<span>CHOOSE YOUR FEATURES</span>
</b>
</div>`
I've been concentrating on using div class 'personalizationButton' but perhaps I need to point to that 'b class'? Just not sure how to format it. Here are some examples of what I have tried
$browser.div(:class, 'personalizationButton').when_present.click
$browser.button(:text => 'CHOOSE YOUR FEATURES').click
$browser.button(:div => 'personalizationButton').click
etc, etc... just not sure I'm getting the format right. I watch it get to the page, I see the 'CHOOSE YOUR FEATURES' button on the page, but it never clicks it. Usually I get an error like this depending on which version was used:
unable to locate element, using {:text=>"CHOOSE YOUR FEATURES", :tag_name=>"button"}
This is the version I think should work, When I try it I get no errors but see nothing happen in the browser either:
$browser.div(:class => "personalizationButton").click
I'm not seeing anything inherently clickable (with output) in the HTML. With the IRB output, it shows that it is finding the div, but there is no action when clicking it. The <b> element is just the "bold" style, so we shouldn't need to try that.
If you can access the span with text CHOOSE YOUR FEATURES, that should be your button.
$browser.span(:text => "CHOOSE YOUR FEATURES").click
. . i have tried doing the same thing with godaddy.com buy it did work.
on the main page there is a button labeled "Buy Now" using the code below
brow.div(:class => 'gdhp-domain-link gdhp-rounded-corners').span(:text => 'Buy Now').click
I was

Resources