How to set cursor at the end of line for text-box in nightwatch - nightwatch.js

I want to click at the end of text for text-box and write some text there. when I use .keys() it begins to append in middle

This might work in selenium Sendkeys but not in Nightwatch js as far as I know.
You can achieve what you are trying to do by doing the below steps.
Read the current value in the field
Append the text you want to add
Clear the content of the field
Keys can be used to set the full text into the field.

Did you try to use .setValue() ?
From the API link https://nightwatchjs.org/api/setValue.html:
setValue does not clear the existing value of the element. To do so,
use the clearValue() command.

Related

How copy a value that's text on cypress?

I've a selector assigned for a text value, I want to copy the value that's being displayed. How can I do this? The text value is saved in a span tag.
Dummy Text
cy.get('text-value'). and then what can I apply to do this action?
Saving the text of an element usually works like this:
cy.get('selector').invoke('text').as('variable_name')
Then you can call this variable in a later itinstance with
this.variable_name
for example you want to type the text you save in another field:
cy.get('other_selector').type(this.variable_name)
Just note that you can't put them inside the same it instance because of the asynchronous nature of Cypress

How to add default value to text field that cannot be changed (Ruby on Rails)

I am trying to create a formatted text field that will have its contents then parsed into a Ruby Date object. I think I have the logic for taking a value from a text field and turning that into a date, but I can't figure out the formatting part.
I want a text field that would already have separators in it by default, that the user could not overwrite. So I would want the text field to look like:
__/__/__
And when they tab into the field, the text they type fills in the spaces instead of overwriting everything in there.
Thanks!
not sure about the ruby but you can use jQuery like so:
http://digitalbush.com/projects/masked-input-plugin/
jQuery(function($){
$("#key").mask("aaaaa-aaaaa-aaaaa-aaaaa-aaaaa");
});
and simply use <noscript> in your page header to make sure anyone's viewing your page has the javascript enabled.

How can I change the title ckeditor sets for inline instances?

Right now it sets it to Rich text editor, element_id. Is there any way to change that?
In ckeditor.js search for the following string:
a.changeAttr("title",c)
And justs set it to an empty string if you want:
a.changeAttr("title",'');
Keep In mind, you'll lose this during an update, but this is the only way until they add it to their editable configurations. Only use this if you don't mind losing some a11y.
This title is set in CKEDITOR.editable. You can change it by:
modifying this code,
changing translation in lang/<your lang>.js (e.g. https://github.com/ckeditor/ckeditor-dev/blob/master/lang/en-gb.js#L30)
But when you'll modify it, remember that this title is there to provide a11y.

Selected text in ruby Tk Text widget?

I can't seem to find how to get the currently selected text from a Text widget in ruby. In perl there was a ->getSelected function, which does not seem to exist in the ruby implementation. Also, the selected text is supposed to be marked with a tag "sel", but whenever I try to use it with get("sel"), it says invalid text index. There must be a way to get the selected text though...
Also, another question, by default, the text widget in perl has a pop menu with all sorts of functionality like search, copy/paste. Was this just a perl specific add on?
Yes, the popup menu in perl is a perl-specific add-on.
As for getting the selected text, you are correct that the selected text has the "sel" tag, and you use that to get the selected text. To retrieve the selected text you should use the index sel.first and sel.last, for example:
get("sel.first", "sel.last")
A really good resource on Tk that covers usage in Tcl, Python, Ruby and Perl see tkdocs.com. The text widget is documented on that site in the tutorial on text.
Of course I finally figured this out right after posting. The index is "sel.first" and "sel.last". so I used get("sel.first", "sel.last")

Adding Hyperlinks to created Bookmarks in a Word documnet using Ruby

How do you add a Hyperlink to a word document using an existing bookmark. I have been testing using IRB but continue to get Command Failed.
I have attached to a running word application have text selected that I want to tie to the hyperlink. For testing I have been trying to just add a google hyperlnk. I figure once I get that then I would be able to figure out the bookmark. This is the command I am using
doc.Hyperlink.add(word.selection, 'http://www.google.com', '','','text to display')
The two blank parms are for SubAddress and ScreenTip respectivly.
Luke-
You're very close...
Change this...
doc.Hyperlink.add(word.selection, 'http://www.google.com', '','','text to display')
...to this...
doc.Hyperlinks.add(word.selection.Range, 'http://www.google.com', '','','text to display')
There were two changes necessary:
(1) You call the Add method on the Hyperlinks (plural) collection, and (2) the first argument needs to be a Range object.
With these changes, your code works for me.

Resources