How to paste using the keys command in nightwatch? - nightwatch.js

How can I paste in nightwatch? I tried this command:
browser.keys([browser.Keys.COMMAND, browser.Keys.v])
But the command is not working.
Ideally I would lake to be able to save the copied text into a variable.

This is working for me, try this:
browser.keys([browser.Keys.CONTROL, "a"]) // highlight text
browser.keys([browser.Keys.CONTROL, "c"]) // copy text
browser.keys([browser.Keys.CONTROL, "v"]) // paste text

I had to add the third NULL parameter to all commands, not only the last one, then it worked. Sadly, I can't find any documentation about how this exactly works.
My usecase was selecting everything on a page with an image on it (ctrl+a), copying it (ctrl+v) and then navigating to another page with a CKeditor on it. Focussing on the ckeditor and pasting (ctrl+v) the image.
.keys([browser.Keys.CONTROL, 'a', browser.Keys.NULL])
.keys([browser.Keys.CONTROL, 'c', browser.Keys.NULL])
.keys([browser.Keys.CONTROL, 'v', browser.Keys.NULL])

The below command worked for me to hit ENTER KEY .
browser.keys([browser.Keys.ENTER]);

Related

How to fix 'Link Highlighting in Inline Code'?

The method of writing a code element in Asciidoc is by writing an element enclosed in the grave accent(`):
`var`
And, the method to show a link is:
link:www.awebistelink.com[var]
I am attaching an image to show these two on a website that renders Asciidoc
Image Displaying the output in an asciidoc document
When I am trying to show a link highlight of a code element inside an inline code by writing:
`link:www.awebistelink.com[var]`
It renders perfectly fine on Asciidoc Please see it here
But on the website, it doesn't show any link, and simply shows a code element like as if we declared it simply as
`var`
The correct way to make a link label appear in monospace is to apply the backticks to the label itself, not the link.
Using your example, the markup should be:
link:www.awebsitelink.com[`var`]
I found the answer,
it should be
`link:www.awebistelink.com[var]`
I still don't know how it worked but now it works just fine as intended.

How to insert an inline image in Google Colaboratory from Google Drive

I am trying to insert an image in Google Colaboratory (markdown) already saved in Google Drive using this expression ![Text](https://xxxx) but it doesn't work. For example, the Colaboratory markdown manual shows how to insert a photo inline with this example An inline image: ![Google's logo](https://www.google.com/images/logos/google_logo_41.png). Ok, that is a photo from internet, but, when I replace that photo for one already saved in my Google Drive it doesn't appear.
If you have a link like this, then I've got a solution.
https://drive.google.com/file/d/-------/view?usp=sharing
In Google Drive, right-click on the picture
Choose 'Get a sharable link'
Click to 'Copy link'. You need reader permissions. Just need the id of the image.
In my case my link is:
https://drive.google.com/file/d/1xDrydbSbijvK2JBftUz-5ovagN2B_RWH/view?usp=sharing
Now we need to copy JUST the image id:
1xDrydbSbijvK2JBftUz-5ovagN2B_RWH
We will use this base link to generate your link with the image id:
https://drive.google.com/uc?export=view&id=your_id
We then copy the id in the link:
https://drive.google.com/uc?export=view&id=1xDrydbSbijvK2JBftUz-5ovagN2B_RWH
Finally, to place as an image in Google Colab:
![](https://drive.google.com/uc?export=view&id=1xDrydbSbijvK2JBftUz-5ovagN2B_RWH)
I tried all the answers above and nothing worked because of a small change Google has created recently(at the time of writing this post). If you click on "Get Shareable link" and paste it, it would look something like this:
https://drive.google.com/open?id=12BumFEqzKxc9mog8tYuUqvpxf10ot6W3
Now just change the open?id to uc?id and it will instantly work.
According to the answers here
![](https://drive.google.com/uc?export=view&id=XXX)
From the next 3 formats only the first one worked for me:
![](https://drive.google.com/uc?export=view&id=0B3SU50kcW4Q4WFlla00tX3hkdkE)
![](https://drive.google.com/file/d/0B3SU50kcW4Q4WFlla00tX3hkdkE)
![](https://drive.google.com/open?id=0B3SU50kcW4Q4WFlla00tX3hkdkE)
Here is an example using plain html instead of markdown.
<figure>
<center>
<img src='https://drive.google.com/uc?id=1Rb6oXW3KufLApvID5MwxsknpoON2CkQ_' />
<figcaption>Image Caption</figcaption></center>
</figure>
This way, you can also center the image, add captions etc
Unfortunately, I have tried the methods above but they didn't work for me. Then I have tried simply right-clicking on the picture that I want to display on colab, and choose 'Get a sharable link', then the link is automatically copied to my clipboard:
The link will be something like
https://docs.google.com/uc?id=-----
Then using colab's picture inserting button, and insert that link to the (https://) part
![picture](your link)
worked like a magic!
However, if you get a link like this
https://drive.google.com/file/d/-------/view?usp=sharing
after making picture public, it somehow doesn't work.
This below method works for me:
Upload the image on google drive.
Enable link sharing (Right click on image > Get shareable link)
Change access type from 'Restricted' to 'Anyone with link', keep role as 'Viewer', click 'Done'(pop up should close).
Double click on image, Spot 'More actions' icon(top right corner, 3 vertical dots).. click on it and next select 'Open in new tab' from the more action menu, a new windows opens.
Now again, spot 'More actions' icon(top right corner, 3 vertical dots).. click on it and select 'Embed item'. It will give you a HTML 'Embed snippet'.
Copy that HTML snippet and paste it in your Colab noteboook inside a markdown or code cell.
If you use a code cell, you can use magic function %%html (change iframe width and height for your needs).
%%html
<iframe src="link_placeholder" width="600" height="300"></iframe>
I tried all of the above methods, and nothing works for me. However, there is a workaround that bypasses the use of Google Drive altogether: Simply insert the image as Base64 data in normal HTML like so:
<img src='data:image/png;base64, ...lots of base64-data.. style="max-width:100%;" />
If you, for example, are using draw.io to draw a diagram that you want to include, there is a handy option for embedding data (under file->embed). If you choose "image" in this menu, you'll get a pop-up with the relevant code for you to copy. Otherwise there are image to base64-converters online that you can use.
The downside of this method is that you'll end up with a lot of data to paste. However, if you use a dedicated cell for this purpose, there won't be any need to edit that cell ever again.
(As a side note, this method works in most Markdown editors if you for some reason are unable to include an image file. Sometimes it will also work to use SVG data instead of base64, but this does not work in Google Colab.)
Here are my solutions. I liked the first one more.
First Solution :
Step1: First use a wget to fetch the picture, do not use svg file! just png
!wget https://upload.wikimedia.org/wikipedia/commons/thumb/3/38/Jupyter_logo.svg/207px-Jupyter_logo.svg.png
Run the code
Step2: Get the name of the file from last line '207px-Jupyter_logo.svg.png', after you run the wget.
from IPython.display import Image
Image("207px-Jupyter_logo.svg.png")
Run the code!
Second Solution:
use the code below and use png file
from google.colab.patches import cv2_imshow
!curl -o logo.png https://colab.research.google.com/img/colab_favicon_256px.png
import cv2
img = cv2.imread('logo.png', cv2.IMREAD_UNCHANGED)
cv2_imshow(img)
So enjoy :)
Solution for svg or other type of files
![This is an image](https://.......svg)
Anyway, use your link :)
3rd from Github_md_guideline
Once you get the public URL of the image, you can insert it in a Markdown cell
With
![Image in a markdown cell]( https://i.imgur.com/6Z1i8zF.png)
Or in a Code cell (this trick is just in Colab, as far as I know)
With
##markdown ![Image in a code cell]( https://i.imgur.com/6Z1i8zF.png)
So you can have Markdown within a code cell.
Link to shareable image is restricted to unique code associated to that picture. Once you update the picture (happens), then you need to update the link too.
Alternative ways are described here . My solution is given there too, so I will not copy past it here.
You can simply copy the picture in the clipboard and paste it in a markdown cell

Javascript : get content from clipboard with formatting

I have a requirement to customise(filter) copied content(from any source) before pasting into my content editable div.
I am using javasctipt window.clipboardData.getData("Text") to get copied content from clipboard. However this method returns only the plain text. I want to get the copied content as is without loosing its formatting. How can I do it? window.clipboardData.getData("Html") doesn't seems to be working. I am using Internet Explorer 11.
you can try with this
var $temp = $("<input>");
$("body").append($temp);
$temp.val($( this ).attr('name')).select();
document.execCommand("copy");
$temp.remove();
and paste

Single quote in CKEditor

I'm using CKEditor and I have a problem when I try to add single quote to the database. Everything else works perfect but if my text have single quote it won't work.
If I try to add for example 'test' and if I then click on source in a CKEditor toolbar I see 'test' , but when I want to add it to the database it doesn't work.
Any ideas?
Thanks.

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