Focus change on control Autoit - autoit

I have a application window with two text fields (no access to the application code, so cant change anything). User scans a barcode in the fields, the action "enter press" is programmed in the scanner and cannot be changed. I need to validate the fields before enter is pressed, I can validate the first field but the issue is I need to validate the second field before enter is press(which is through the scanner). Is there a way this can be achieved using AutoIT? I hope the question make sense.

Use the "AutoIt v2 Window Info" tool (Au3Info.exe) to identify the two edit controls. On the "Control" tab you find the "Advanced Mode", which will show data like "[CLASS:Edit;INSTANCE:2]". Now use this information to read the data of the control:
$Text1 = ControlGetText('window title', '', '[CLASS:Edit; INSTANCE:1]')
$Text2 = ControlGetText('window title', '', '[CLASS:Edit; INSTANCE:2]')
See the example here: http://www.autoitscript.com/autoit3/docs/functions/ControlGetText.htm

most barcode scanners can be programmed to not send the terminator (enter) usually by scanning a couple special barcodes in the users manual
I program scanners with special terminators so our program can tell the input was from a scanner and not key presses

Related

Telegram Bot. How set command /cmd in user text input?

I need to create command (for example - /cmd). When user click on this command in list - bot set this command text(/cmd) in user input and user should input argument for this command. How to do this?
Example:
I have command /cmd. And when user input is - "/cmd parameter1" it goes to execute command with this parameter. I need to allow the user not to enter "/cmd" - it will add it automatically.
Based on question & comments;
bot set this command text(/cmd) in user input
A regular Telegram bot can't place text in Input field. This is only possible with an Inline bot.
If you wish to 'ask' the user a specific 'argument' based on the /cmd command. You could use an Inline bot, an Keyboard to list all available 'arguments' or ask the user, and 'wait' for a reply.
You could also show all available command with an Keyboard and then change the keyboard to the available arguments with on-the-fly updatable inline-keyboard

Contact form 7 plugin wordpress - How to send email of filled values only

I have a form that has some optional fields but if a user doesn't fill them out the label of the input will be sent in the email and they will be empty. so for example if a user doesn't enter a city field the email will say City:
Is there a way to set conditionals where if a user doesn't enter optional fields the label wont be sent?
http://wordpress.org/plugins/contact-form-7/
Short answer: yes, but.
Long answer: Wpcf7 has events for on send and others that you can hook into to extract and manipulate the data it has at the time. It's not a well documented aspect of the plug in, because it's really intended for the developer themselves to use, but you can write add_hook commands into your functions . php file and then use your own functions to change the output.
I think the send hook is called "wpcf7_send" so you can write a function like this:
function beforesend($obj) {
//manipulation of message here
}
add_hook('wpcf7_send', 'beforesend');
It's only a starting point but by exploring a bit you can find the hook names, and class structures you need.

What is the most efficient way of filling in details on a web form?

Take a standard web page with lots of text fields, drop downs etc.
What is the most efficient way in webdriver to fill out the values and then verify if the values have been entered correctly.
You only have to test that the values are entered correctly if you have some javascript validation or other magic happening at your input fields. You don't want to test that webdriver/selenium works correctly.
There are various ways, depending if you want to use webdriver or selenium. Here is a potpourri of the stuff I'm using.
Assert.assertEquals("input field must be empty", "", selenium.getValue("name=model.query"));
driver.findElement(By.name("model.query")).sendKeys("Testinput");
//here you have to wait for javascript to finish. E.g wait for a css Class or id to appear
Assert.assertEquals("Testinput", selenium.getValue("name=model.query"));
With webdriver only:
WebElement inputElement = driver.findElement(By.id("input_field_1"));
inputElement.clear();
inputElement.sendKeys("12");
//here you have to wait for javascript to finish. E.g wait for a css Class or id to appear
Assert.assertEquals("12", inputElement.getAttribute("value"));
Hopefully, the results of filling out your form are visible to the user in some manner. So you could think along these BDD-esque lines:
When I create a new movie
Then I should see my movie page
That is, your "new movie" steps would do the field entry & submit. And your "Then" would assert that the movie shows up with your entered data.
element = driver.find_element(:id, "movie_title")
element.send_keys 'The Good, the Bad, the Ugly'
# etc.
driver.find_element(:id, "submit").click
I'm just dabbling in this now, but this is what I came up with so far. It certainly seems more verbose than something like Capybara:
fill_in 'movie_title', :with => 'The Good, the Bad, the Ugly'
Hope this helps.

How can I click on a specific email at Gmail using Selenium IDE?

I am trying to run a test on selenium IDE to enter to my Gmail, select the specific new email from all my email enter and click on a specific link that the email has.
I've been going round and round this and cannot find and answer!
I have read another post that has this help:
//div[#class = 'y6']/span[contains(., 'subject here')]
This does not help because the same email has been sent lots of times.
This case has the following particularities:
1. Since is a case that it will be run several times, emails with the same sender, subject and body will be send.
There should only be one new email every time the test is fun, since the idea is to enter and check the last email.
Inside the email there is a button that needed to be press, which I have the id, but I just need to enter the email to do so.
I have used the following CSS that so far has found what i need to click, but when I ask Selenium IDE to click it, it does nothing (clickAt, clickAndWait, clickAtAndWait... nothing!)
css=div[class=yW] > span.zF:[email='myemail#myemail.com']
I have also notice that the class="zA zE" in Gmail indicates that the email has not yet been read.
Help!
Thanks,
This is strange, because clickAt | css=div.yW > span.zF[email='myemail#myemail.com'] works fine for me. More than that, clickAt | css=span[email='myemail#myemail.com'] will always open first message(last one) with this email in the list.
BarbSchael,
A similar solution can be drawn by using Xpath of the FROM field.
I used this command:
clickAt | //table/tbody/tr/td[5]/div[#class='yW'] |
Click at the FROM field of first/recent/top most mail to go to mail detail page. // note: tr for first mail, tr[2] for second and so on.

How do I take keyboard input in AutoIt?

I want to write a script in AutoIt, which can take automatic input from the keyboard, let's say A-Z, without user intervention.
Is this possible?
It is unlikely that your program needs to capture all input from all keys. If you do in fact need that kind of user input AutoIt might not be for you - see the post from the author of AutoIt about keyloggers. If you need to take keyboard input of the hotkey type: doing that in AutoIt is super easy.
HotKeySet("^+{q}", "reactionFunction")
While 1
; A loop
WEnd
Func reactionFunction()
MsgBox(0, "You pressed CTRL+Shift+q", "You pressed CTRL+Shift+q")
Exit
EndFunc
If you want to take user input from an input box that is really easy also.
$data = InputBox("Enter Something", "Enter some data in the field below.")
MsgBox(0, "The String You Entered...", "The string you entered is... " & $data)
More information about HotKeySet and InputBox can be found in the AutoIt.chm help file (it's actually a great reference).
Not sure I understand your question - you want to simulate keypresses without someone actually using the keyboard? If so, that's the send command in AutoIt.
You want to let a real user submit input to the script? That's what the GUI in AutoIt is for.

Resources