DalekJs : Key code for the 'Enter' key with sendKeys - unicode

I am trying to simulate the Enter key like it is done with the Escape key in this exemple :
test.open('http://home.dalek.com')
.sendKeys('body', '\uE00C')
.assert.dialogText('press the escape key give this alert text')
.done();
I can't figure out what code should be used to simulate the Enter key.
Do you know a ressource listing the key codes that could be used with the sendKeys function ?
Thanks

That's UTF-8 encoding, here you have the some handy codes
Return U+E006
Enter U+E007
Loads of literature available at wikipedia

You can also use the unicode-keymap NPM module to get an object with the entire character types mapping from the W3C WebDriver spec.
To install:
npm install unicode-keymap --save
To use:
var keys = require('unicode-keymap');
keys.Enter
// -> \uE007

There's good character types table for sendKeys action in W3C WebDriver spec.

In Java you can do this also this way:
WebElement webElement;
webElement.sendKeys(Keys.ENTER)
webElement.sendKeys(Keys.Shift, "a")
...and so on.

Related

how to verify text present in placeholder in selenium IDE

I want to verify the text present in placeholder. I have located the element and i am using Assert text command. I've entered the same string in value. On executing it is showing actual value did not match
Use assertAttribute or verifyAttribute command.
Example:
verifyAttribute | css=#search#placeholder | Sample String
Notes:
In the Target column of Selenium IDE, you need to provide the proper path of the element followed by an # sign
and then the name of the attribute. (placeholder in your case)
Using
verifyAttibute will still continue running the test case once an
error is detected while using assertAttribute doesn't.
You need to understand that assertText function can only check static text on your webpage.
You must be getting an error message.
This is perfectly normal.
What can help in this situation is using the assertAttribute or verifyAttribute functions.
Both these functions perform the same task; the former stops the test after receiving an error message in the text box while verifyValue just records the error in the log and runs the next commands.
While giving the target, either specify the XPath or refer by using the name=name#placeholder format.
You can find the name value by inspecting the box with a firefox addon called Firepath which runs with another firefox tool called Firebug. Install them if you don't already have.
Hope this helps!
Xpath contains() is the best way.
driver.find_element_by_xpath('//input[contains(#placeholder,"email")]')
Format : '//tag[contains(#attribute,"value")]'

Protractorjs testing - how to use :contains('someText') - possibly escaping strings incorrectly

I have an angular form that I need to test and I want to select an item without an identity, via its textnode contents. In jquery and selenium on other platforms, I was able to use a special css selector called :contains() which allows me to find stuff
ptor.findElement(protractor.By.css('label:contains(\'some text\') > input')).getAttribute('value').then(function (value) {
expect(value).toContain('myExpectedValue');
});
When I run this I get a lexical error about invalid string. I've tried a variety of ways to escape the quotes in the string. I have also tried an xpath expression, which did the same thing after introducing quotes. It looked something like this:
ptor.findElement(protractor.By.xpath('//label[text()="some text"]/descendant::input[1])')).getAttribute('value').then(function (value) {
expect(value).toContain('myExpectedValue');
});
That failed the same way.
1: Is the :contains selenium function available in protractor?
2: Am I escaping my strings wrong?
Please don't tell me to attach an identity to the object. I am not allowed to modify the markup.
You can't use :contains with the protractor.By.css locator because :contains is not part of the CSS3 spec (see here)
I don't know what's wrong with your xpath, but it's not the escaping. I've used xpath strings like that in protractor.
Update:
In response to the lack of ‘:contains’ selector a new locator was created for this purpose:
Example: By.cssContainingText(‘ul .pet’, ‘Dog’) will find all ul children with class ‘pet’ containing the text ‘Dog’. Read more about it here
Note: you might need to update since older versions of protractor don't have this selector.

Using barcode scanner to read barcode in forms 10g

I want to use barcode to read instead of using input from keyboard. I use Key Enter trigger and passing null against it but it did't fire. Any solution.....
I Googled for it and found this article. The pertinent line is
"In order to cause the key-next-item to execute you will need to ensure
the bar code reader sends a TAB key sequence at the end of each scan
so that the key-next-item trigger will fire."
I don't know whether that will solve your problem but the solution will probably be something along those lines: configuration of the reader.

Sinatra encoding query string

I've made a very simple sinatra application which displays a frameset with 3 frames. When I set the 'src' parameter for the the frames however, sinatra re-encodes the query string I chose.
For example I enter:
"url.com/page?var1=val1&var2=val2"
What I end up seeing however is something like:
"url.com/page?var1=val1&var2=val2"
All my &'s were turned into &-a-m-p-;'s. Is there anyway to disable this? Why does this happen?
Thanks,
This is probably happening because you have an "escape all html" flag turned on somewhere. Your template language should support flagging strings as "safe"--check out http://www.sinatrarb.com/faq.html#auto_escape_html for more details.

jboss valve encoding problem while url rewriting

I have an app., coded with ejb3, jsf and maven, which runs on jboss 4.2.2GA
The problem I have been facing for 2 days is I cannot convert non-english characters that are added to url on runtime. For instance, there is a search textbox and a button. When a user enters a word including non-english characters, and pushes the button, it is added to the url with bad characters like %56 or &347 etc..
Is there any way to achieve what I am trying to do here? BTW, is there also any way to get over this problem on the jboss side configuration rather than application side (filters or context.xml etc..)?
Any help would be appreciated
Thanks a lot,
Baris
--
EDIT: I have solved this issue by using URLEncoder. When I passed the variable to the action method, I use URLEncoder in order to encode it to the right charset.
Example:
Take parameter from the URL:
String someString = ServletActionContext.getRequest().getParameter("someStringFromURL");
Encode the string;
String encoded = URLEncoder.encode(someString, "ISO-8859-9");
Find the appropriate connector element in your tomcat server.xml (deploy/jboss-web.deployer/server.xml for recent versions) and add the attribute URIEncoding with a value of UTF-8.
I have solved this issue by using URLEncoder. When I passed the variable to the action method, I use URLEncoder in order to encode it to the right charset.
Example: Take parameter from the URL:
String someString = ServletActionContext.getRequest().getParameter("someStringFromURL");
Encode the string;
String encoded = URLEncoder.encode(someString, "ISO-8859-9");