I am testing a Magento POS application with Selenium IDE. There is a auto complete textbox, where I need to put the product name. As the auto complete textbox works, when we started typing, it starts searching. I tried a lot, but still I am unable to figure out how to test that in Selenium. I have tried the below command
typeAndWait(selector,sony)
verifyText(class=ui-autocomplete:first-child,sony)
click(class=ui-autocomplete:first-child)
But it is not working. Any help? I don't understand, what to do ?
Use waitForText instead of verifyText
Use pause or waitfortext command after type command
instead of typeandwait use type command
use this code
type(selector,sony)
pause 2000
verifyText(class=ui-autocomplete:first-child,sony)
Actually you need to fire the events associated with the textbox.
instead of type use typekeys command
and insert a new command
click (path of autocomplete text box)
and also insert new commmand
waitforvisible (path of the value to be verified)
now put your command
verify text(path of the value to be verified,sony)
Try below code, it might work:
Type the required auto-complete name like Sony (use TypeAndWait command & add auto-complete id)
Use typeKeysAndWait command for auto-complete dropdown
Click on auto-complete dropdown id
TypeAndWait(class=ui-autocomplete:first-child,sony)
typeKeysAndWait(class=ui-autocomplete:first-child,sony)
click(class=ui-autocomplete:first-child)
Related
I'm developing an automation process on SAP with Automation Anywhere using the SAP DLLs provided by Automation Anywhere itself. I need to find IDObject with specify attribute to click/get value the specify element , but seems that there are no fuctions that allow you to do it. An example of code generated from the SAP recorder is the following:
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell").setCurrentCell 0,"ICON_EXEC"
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell").selectedRows = "0"
session.findById("wnd[0]/shellcont[1]/shell/shellcont[0]/shell").clickCurrentCell
using the dlls I have already tried the following functions:
Step 1 : Login on existing session (in this case 0)
Step 2 : Search Object by ID (in this case wnd[0]/shellcont[1]/shell/shellcont[0]/shell )
Step 3: CurrentCellRow (in this case 0)
Step 4: DoubleclickCurrentCell
The problem is that it doesn't click where i want, because as you can see there is the attribute "ICON_EXEC" that specify the element that i want to click . (i also tried to insert in the SearchObjectbyID all the string with the attribute, but it doesn't work)
Currently to avoid that i'm using Execute VBscript, but it seems that error handling does not work with scripts, so i would like to avoid them too
Any tips?
Thanks,
U.
You can find out the SAP-Object ID (IDObject) by recording a (.vbs-)macro in SAP:
Hit Alt + F12 or click the respective icon and choose "Record script and playback" ("Skript-Aufzeichnung und -Playback" in my screenshot):
In the following dialogue window, hit the record button and click the desired object:
Open the recorded .vbs-macro and and look for something like this (=the desired object ID):
You can handle errors in sap vb script , please refer below articles as reference and handle error as per you requirement.
1) https://answers.sap.com/questions/9676858/error-while-logging-to-sap-through-excel.html
2) https://wiki.scn.sap.com/wiki/display/Img/Scripting%3A+Error+Handling+and+Debugging
Version : Using HP-UFT Tool 11.53 Build 0382.
Question :Wanted to automate Function key F9 for my script but I am not able to as I do for normal keyboard keys what is method to do so.
Work Done : Try to Record for function key Hitting But no record is create for it.
Scenario : In my application on F9 press one popup would come and I just want to test it using UFT Tool.
You can use sendkeys, if you want to hit any key from keyboard. Try the below code.
Set oWscript = CreateObject("WScript.Shell")
oWscript.sendkeys"{F9}"
In UFT Window has a Type method, the parameter for this method is a string but there are special values for special keys. For you case you probably want micF9.
Please look and Window.Type's documentation for more details.
I am new in selenium and trying to learning. I am creating a script and I got stuck here, I want to store a dynamic value from text message on web page ex. " Event Name:Test" this Event Name is dynamic and I want to store this and want to get in other window. In 2nd window i want to use this value(Test) to verify in the page
I tried storeValue, StoreText and storeAttribute command and getting error message for xpath or "element not found".
Please help me and advice me , what should I do?
Can You please suggest me the Xpath for storing and retrieving the event name. Please help me...
Thanks in advance,
Niru
If you are using the same test-case to navigate from page 1 to page 2 you can use the storeText function in the IDE to store the value of your event name. And then you can use the same variable in the page 2 for verification.
For example, in page 1 to store the value of event you use:
storeText(locator1, temp)
And then on page 2 you use assert:
assertText(locator2, ${temp})
I need to simulate a tab keypress in Selenium RC, using the Java API.
I do this after having entered some text using:
selenium.type(input, "mytext");
I've tried 3 alternatives to get the tab working:
selenium.keyPress(input, "\\9");
and:
selenium.focus(input);
selenium.keyPressNative("09");
and even:
selenium.getEval("var evt = window.document.createEvent('KeyboardEvent');evt.initKeyEvent ('keypress', true, true, window,0, 0, 0, 0,0, 9,0);window.document.getElementsByTagName('input')[2].dispatchEvent(evt);")
The best I can get is a "tab space" to be inserted after my text so I end up with this in the input field:
"mytext "
What I actually want is to tab to the next control. Any clues? Thanks!
(Note: I have to use tab and can not use focus or select to chose the element I want to go to, for various reasons, so no suggestions along these lines please!)
selenium.keyPressNative(java.awt.event.KeyEvent.VK_TAB + "");
I don't use the Java API, but this post from google groups suggests it is your solution. I can't imagine that "9" is different from "09" in your question, but give it a try?
Try the official TAB char: \t or \u0009
Some functions may used Onblur. It will trigger the function when the field lose the key focus. here we can use fireEvent with "blur" or "focus" command as follows:
command: fireEvent
target: id=your_field_identification
value: blur
Reference: http://qaselenium.blogspot.com/2011/01/how-to-triger-tab-key-in-selenium.html
Improvising Ryley's answer, we can use
selenium.keyDownNative(java.awt.event.KeyEvent.VK_TAB + "");
selenium.keyUpNative(java.awt.event.KeyEvent.VK_TAB + "");
I tried this method for VK_CONTROL in IE and it worked good.
Use typeKeys():
Quoting the above link:
Unlike the simple "type" command, which forces the specified value into the page directly, this command may or may not have any visible effect, even in cases where typing keys would normally have a visible effect. For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in the field.
In some cases, you may need to use the simple "type" command to set the value of the field and then the "typeKeys" command to send the keystroke events corresponding to what you just typed.
When using Selenium how can I wait for a popup window if its id is dynamically generated?
For example:
selenium.click("link=mylink");
selenium.waitForPopUp("popup072815372337691199");
Obviously I cannot hardcode the window id in my source code. Any hints?
It would obviously be best to have a consistent or fully predictable window name, however if this is not possible you could try using the getAllWindowNames command to wait until the number of windows increments. If the name of the window is somewhat predictable (like a consistent prefix) you could then find out the full name of the new window before using waitForPopup or selectWindow.
do it this way....
'String href = selenium.getAttribute("link=myLink#herf");
selenium.openWindow(href, "myWindow");
selenium.selectWindow("myWindow");
selenium.click(...);
// do whatever
selenium.selectWindow(null); // go back to the previous window'