Chrome Headless clipboard error - google-chrome

I'm using Chrome Headless for testing purpose. It is used in conjunction with nightwatch.
There is an action that clicks on a button in a page. Unfortunatly the page is not online, but the copy part is done with export:
this.waitForElementVisible('#exportBtn', 6000)
.click('#exportBtn')
This button, using javascript, it copy some content in the clipboard.
[EDITED] The button uses ngclipboard from Angular (https://sachinchoolur.github.io/ngclipboard/)
But when I "paste" the content in another field, the content is not the one copied/expected. The paste is done with:
client.keys([client.Keys.CONTROL, "v"]);
Running the same test in the normal way (Chrome with the UI) there is no error.
For your info: the paste part works, in the sense that it paste something in the text field, but it's not the one copied, it's the last thing copied by myself (from notepad, from word...from everything but outside and before the run of this test)
Any clue or possible error?

Related

Can't enter text from keyboard into a script editor window already containing code

I'm using the latest script editor (rather than the legacy editor). No problem entering text from the keyboard into a newly created script file, but when I try to edit, say, Code.gs, already containing some code, the editor won't accept keyboard input (except Enter, Del) although it allows me to paste code from an external text file.
If I clear (CTRL+X) all the code I can then type into the script window. But pasting the code back reactivates the lock. I'm guessing this may be something to do with the built-in code validation, but I cannot see how to disable this behaviour. I'm embarrassed to have to ask this question. TIA.

How to show the whole source code of load more page after clicking on load more botton?

I have a problem with this page!
when entering it, you can right-click and view the source code via, say, chrome and see the articles with their links..etc. However, when pressing on "المزيد" and viewing the source code again, the source code of the new articles does not appear. Only the source code of the previous articles does.
What would you recommend to solve this problem?
I have pressed on view page source code on google chrome, but nothing appeared regarding the new articles.
The View source option only shows the source code of a page as it was delivered from the server. It does not take modifications performed using JavaScript into account.
The button mentioned in your question loads more content and inserts it into the page programmatically using JavaScript.
You need to use the Elements tab of Chrome Developer Tools to see programmatically inserted HTML code. Right-click anywhere on the page and choose "Inspect", or press Ctrl+Shift+I or F12 on Windows. (Shortcuts on other platforms may vary.)

yii2 and ckeditor, can't paste content

Pasting content from the clipboard to the ckeditor edit field results in a box with the message, that pasting is not possible due to browser restrictions (I'm using Firefox, but it's the same with Chrome). I should paste the clipboards content into the box which works but after clicking ok nothing happens. So I can't paste anything from the clipboard into the editor area.
Inserting a file via the image button works.
What to do to paste content from the clipboard to the editor area?
The problem vanished after copying a new ckeditor version into the appropriate directory under yii's vendor folder.
But I don't know why it works now?

How extension get the text selected in chrome pdf viewer?

I wrote a chrome extension - english dictionary. You select word, the definition appears.
It works well, but I counter a problem. It seems there is no api of chrome pdf viewer supplied by google.
How can I get the word when i select a word in pdf using chrome pdf viewer?
I will be appreciate if you could help me.
You can get selected text using the context menu. In your background script, adding these lines will allow the user to right-click and do something with the selectionText.
chrome.contextMenus.create({id:"lookup",title:"Lookup %s",contexts:["selection"]});
chrome.contextMenus.onClicked.addListener(function(sel){
console.log(sel.selectionText);
});
Grabbing this text works fine with PDFs, whether part of the extension, or not.
However, you cannot inject a script into a page starting with "chrome-extension://". If this is how your extension works, that will not be (directly) possible. But getting the selected text, and doing something with it still very doable.
As an alternative to requiring script injection, see the notification api, which allows a small message to popup, which could contain the definition of the word.

Running a greasemonkey script on a non-HTML page

I have the following fairly basic greasemonkey script:
var newloc = location.href.replace(/^(.*)-xyz-(.*)$/i, "$1$2");
if (newloc != location.href)
location.href = newloc;
That is, it basically strips out "-xyz-" from the URL and loads the page again. So if you navigate to "www.example.com/a-xyz-b/" it'll reload the page at "www.example.com/ab/".
Now, the script work fine if the page is an HTML page. But if I open a .jpg file or something that's not HTML then the script does not run at all.
Is this just a limitation of greasemonkey? That it only works if the page is actually text/html? What is an alternative way this functionality could be done?
Yes, Greasemoney fires on the DOMContentLoaded event, which doesn't seem to trigger on media objects (no DOM).
Get around this by firing on the parent/referrer pages and changing the links there.
Or, if the file names are on the local machine, use a text editor or batch job to rename/rewrite the links/names.
If neither of these workarounds is viable, post the specific details of how you are feeding these URLS to FireFox (name the browser in use if it's not FF).