Selenium IDE: entering ASCII values - selenium

I am using Selenium IDE, and every time I enter an ASCII value the recorder changes it by adding an extra . For example: \9 changes to \\9.
Is there a way to correct this?
Or better yet, is there a better way to simulate tabbing, returns, and other non-character keystrokes?
Thanks!

You can use ${KEY_ENTER} and ${KEY_TAB}. For other keys it is the same as ${KEY_F8},${KEY_ESC}.. etc
Here is a blog post with more details.
http://blog.reallysimplethoughts.com/2013/09/25/using-special-keys-in-selenium-ide-part-2/

Related

Finding element using Xpath worked in IE9 but not in IE11

Attached is the HTML SS I am trying to click a button in my application. The button text is " Reassign". Please note that there is a space before the text. The space is visible when looking in developer tool in IE9. But not in IE11. I am unable to find the element in IE11. Whereas a simple
Driver.findelement(By.xpath(".//button[text()=' Reassign']")).click()
Worked in IE9. Same statement is not working in IE11.
Instead of
Driver.findelement(By.xpath(".//button[text()=' Reassign']")).click()
you could try
Driver.findelement(By.xpath(".//button[normalize-space(text())='Reassign']")).click()
This will ignore any leading or trailing whitespaces.
Maybe using By.linkText() could help, as Microsoft may have implemented it different than By.xpath().
Try both By.linkText('Reassign') and By.linkText(' Reassign'). If neither works, try By.partialLinkText('Reassign'). This is of course not as specific, but, depending on your page, could do.
Check if the below xpath works
//div[#class='divbuttonholder margin-left-none margin- top1']/table/tbody/tr/td/button[#type='button'][#data-bind='click:$root.Reassign']

Instruments fails to execute send_keys intermittently. How should that be handled?

The Problem: I'm using Appium's python client to send_keys to a WebElement.
And Instruments decides it shouldn't tap certain keys sometimes.
This is a pain when I'm trying to do things like login. I need to be able to reliably type or programmatically set values on input fields.
This is (more or less) what I'm doing, and here's the gist of Instruments complaining about it:
el = driver.find_element_by_xpath('//UIATextField[1]')
el.click()
el.send_keys('ABCDEFGHI')
All pretty standard. And it usually works
But usually isn't cutting it. I need something solid.
Possible Solutions?
I think I can make send_keys work if I do some sort of try/retry if I get a WebDriverException back.
But what would be really cool is if I could set the value of the element through a JavaScript execute_script - or better yet - a selenium python binding!
I don't know JavaScript, and I've already tried searching for how to set the value on the object without doing sendKeys but I've come up blank.
Any ideas would be really helpful. Thanks!
Solution below:
# Get the element
el = driver.find_element_by_class_name('UIATextField')
driver.execute_script("au.getElement('%s').setValue('%s')" % (el.id, 'ABCDEF'))
# At this point, the keyboard is opened and the text is instantly entered.

Mysterious FireBug Error repeats with ExtJS

When debugging ExtJS 4 (tried both versions 4.1.0 and 4.1.1), FireBug repeatedly shows the following error: An invalid or illegal string was specified
http://docs.sencha.com/ext-js/4-1/extjs/ext-all.js
Line 18. It does not break on the error, though that option is specified. Additionally, neither my code or ext-debug.js and it's loader seem to actually call ext-all.js.
This error gets logged to Firebug's console about once per minute, which is annoying. What bothers me is that I cannot get the error to go away. Is this a FireBug bug? An ExtJS bug? Aliens? How can I debug the debugger?
I had the same problem before and I've solved it by removing a special character at the end of my JS file! (app.js I think)
It was weird, but the problem came from hidden special characters like: Zero-width non-joiner or Right-to-left mark.
Open another JS file but do not copy/paste your code there. Just write it again and check whether the problem exists or not.
And don't forget to check your data if you have some. As this article explains about the problem: http://www.ashorlivs.fr/javascript-jquery/article/an-invalid-or-illegal-string-was
For general debugging see this link http://www.sencha.com/learn/debugging-ext-js-applications/
You can also use ext-all-dev.js while in development mode.
There is another excellent tool on top of firebug, at this link http://www.illuminations-for-developers.com/
PS: I still didn't figured out how to post a comment. I guess it comes when I have more points/reputation. Hence adding it as an answer. thanks.

Selenium IDE:After Recording the Application Functionalities in IDE,i use the tool to run.But,it is showing error like:

[error] Element //div[#id='divProjects']/table/tbody/tr/td[6]/i not found
i tried to use xpather,firebug inorder to find the id's and values of the object.But,it is not working for me.
please help me to solve my issue.
You can share the IDE script, it'll make easy to resolve the issue. You have to verify that you have got to the element when you are trying to perform any action on it.
Your xpath needs to be more relative. One thing you can try is to change the xpath to xpath:relative while recording in IDE. You can find this option on clicking on the dropdown

Is there a way to make actions optional in Selenium IDE?

This is a bit of a newbie question, but... is there a way to make actions optional in Selenium IDE? I'll provide a use case.
In the app I'm testing, users see a "hey, you're agreeing to the ToS by logging on"-type modal window at the beginning of each session. They have to click OK to continue, and they don't see the window again until the next session.
Based on what I've seen so far, I need to have one test suite for the first test each day, and a second test suite for all the others. The second suite is exactly the same except that it doesn't have the "click okay to dismiss the initial modal window" step. Alternatively, I could just remember that my first run of the test each day will fail, and that I have to run the test again.
Both of those "solutions" seem unnecessarily awkward. Can I just make the click command optional?
Create a javascript file called user-extensions.js with the below code. Then go into the Selenium IDE Options dialog and select your user-extensions.js file, restart Selenium and you'll be able to choose TryClick which will work the same as Click but suppress any errors.
Selenium.prototype.doTryClick = function(locator) {
try {
return Selenium.prototype.doClick.call(this,locator);
} catch(err) { return null; }
};
Perhaps overdue, but for future searchers.
You could use the if and endIf statements within the IDE.
If you are using cookies to decide whether to hide the ToS dialog, you could check that a certain cookie is set and if so, skip the click.
I haven't used the selenium IDE much, but I think doing the check would be much easier if you are using a programming language. I am not sure how to do it in HTML tests.
If you are using HTML, you could have a look for Selenium IDE Flow Control and see if that can do what you need. I haven't used this myself, but if looks like it supports if statements. You could use verifyCookie to check if the cookie exists.
Hope that helps.
As aj.esler pointed it out Selenium ID Flow control is a good solution that has worked for me.
Here is the Firefox add on
I use the gotoif, here is an example about how you can use it. When skip value is 1 then it will go to the label=jump line and will not execute everything from gotoif like to label=jump .
Another extremely useful flow control add-on for the IDE is SelBlocks
It will give you the ability to use: if/else/for/foreach/while and even a way to read variables from an XML file.
Use http://wiki.openqa.org/display/SEL/flowControl addon.
Make something like this :
1.storeElementPresent | //button[#name="cookie_law_accept"] | cookie_law
2.goToIf | storedVars['cookie_law']!=true | end
3.click | //button[#name="cookie_law_accept"]
4.label | end
Explain:
1.If element is present it will be stored as a "cookie_law" with value "true"
2.If cookie_law is not "true" - go to label "end" - other way go to next step
3.Click to cookie accept button (only when itsenter code herepresent because it its not - you go to "end" label and you skip this command)
4.You go here if there is no cookie law button :)