how to click the link using autohotkey in chrome - autohotkey

I'm new to Autohotkey but i'm doing this script where I need to click the link in order to view the printable version of the page. What I do so far is I'm trying to find the link text then clicking enter but no luck opening that link using this method. Any Idea to click this link?
my script so far
Send ^f
Sleep KeySleepSlow
SendRaw Printable Version
Sleep KeySleepSlow
Send {esc}
Sleep KeySleep
Send {enter}
This is the source site and as you can see from the top left "Printable Version" link and on the side is the inspected elements of that link.
Hope anyone enlighten me on this one .

The problem: that's not a proper link
You're struggling to activate that "Printable Version" text that way because, as the source code you shared shows, you don't have a proper link that can be activated with the keyboard! That's just a piece of text (<span>) with an onclick attribute stuck into it that calls the JavaScript function generatePrintWindow, written somewhere else by the page's author, when it's manually clicked with a pointing device.
A solution: click() it with javascript:
For peculiar cases like this, I suggest sending a click to that element with a javascript: URL in the address bar, like this one:
javascript:document.querySelector("#mMainHeader_mHeaderPrintSummary").click()
Here, #mMainHeader_mHeaderPrintSummary is a selector that retrives the element you want to send the click to. That's a # sign followed by what's in the id= attribute you see in the source code.
Or, in this case, you can just call generatePrintWindow because that's all that "link" does!
javascript:generatePrintWindow()
On a browser: focus the address bar with ^L or !d, type one of these, then hit {Enter} to run.
Here's the revised AutoHotKey code:
SendInput ^l{Raw}javascript:generatePrintWindow()
Send {Enter}
Explanation:
SendInput sends the keys to the browser in a nearly instantaneous fashion
^l focuses the browser's address bar
then {Raw} disables the special interpretation of special characters so that we can send the javascript: URL unclobbered
This command runs without any delays and you should only barely notice the action happening in the address bar, if at all.
Test
I wrote part of the HTML I saw on your screenshot here
https://gist.github.com/diogotito/08bb3b01fa236616c750b23c25c6025b
Then I tested the above lines of AHK here
https://bl.ocks.org/diogotito/raw/08bb3b01fa236616c750b23c25c6025b/?raw=true
and the AHK commands worked for me without any Sleep commands in between.
However, this might not work on Firefox due to an open bug regarding bookmarklets and CSP.
P.S.
If you ever want to activate an actual activable link with the keyboard on Chrome, I suggest pressing Ctrl⏎ (^{Enter}) from the Search bar after you get the desired link highlighted instead of hitting Esc then ⏎.
Saves a keystroke!
On Firefox it's even better: just type ' to start searching in the links only, F3 to jump between matches, then a single {Enter} to activate the currently highlighted one.

Related

write a vscode extension visual test

I created a VSCode Extension and then I need to write some tests.
I am using Mocha and chai.
I wrote a few tests and I don't have any issue with that part. My problem is with the below scenario:
I have a button, when I press that button, an input box will appear and then I need to key in a value in the input box and press the okay button.
Can you help me with how I can simulate this scenario by a test? should simulate press the first button by calling the Command palette but how to key in value in the input box?
** Please take note that I already wrote the function test, but the user wants to test the UI also.
can you help me in finding an example related to my problem?
There is something like vscode-extension-tester which lets you test the GUI very comfortable. All information you can find on its github main page:
https://github.com/redhat-developer/vscode-extension-tester/wiki

Silent printing on clients printer for a hospital front desk ADF project

I am working on a Hospital front desk ADF project, here I need to generate visit slips these dont require print preview.I want to get to print the slips without any print dialogs nor do I want a popup window. I tried lot of stuff found on the net but nothing solid has come up..
Tried this.print on the Jasper report, tried the same through Java but I am getting dialog.
I am working on an intranet so the security aspect is out of the discussion so how so I make this work?
This is a suggestion rather than an answer, but I can't write comments before I get 50 points of reputation (thank you for the warm welcome, StackOverflow!) - maybe one of these will help:
1) Printing an html file using java without showing print dialog to the user
2) How would I suppress the print dialog in this example?
I was able to perform the silent print, I used a popup window to call a servlet which generated the required visit slip and displayd the same on the pop window. For the silent print I used
exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT, "this.print({bUI: false,bSilent: false,bShrinkToFit: true,printParams:this.getPrintParams().constants.interactionLevel.silent});this.close();");
I had to make a couple of changes to IE, I added my url to the trusted site option in IE. I enabled js in acrobat and also pointed acrobat to the trusted sites in IE. This resolved silent print but am stuck with another issue..
I am not being able to close the window once print is done.. I tried this..
"var win = window.open('PrintPopUp.jsf','_blank',\"height=300,width=200,scrollbars=no," +
"status=no, resizable=no, screenx=0, screeny=0\");win.onclick=function(){setTimeout(function(){win.close();\n},9000);}
But its not working in IE 11.. any suggestions?
Well I found out a way to do this..
JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT,
"var pp = this.getPrintParams();pp.interactive=pp.constants.interactionLevel.silent;pp.NumCopies=1; this.disclosed= true ;this.print({bUI: false,bSilent: false,bShrinkToFit: true,printParams:pp});");
This adds pdf javascript to the generated pdf..
Once the pdf is displayed on the popup page it performs the silent print.. Hope this helps someone in the future..

fiddler autoresponder not working

I added a rule (flash file), specified the new flash file I want fiddler to respond with (use instead of the browser one). I've cleared my browser cache, and every time I play the stream, the browser flash file is captured again (instead of auto-responding) with the one saved already!!!
It used to work just fine, but now it appears as if the auto-responder (although checked) is not working at all...it's just a pass-through!!!
As explained in the forum post where you asked the same question
There are three possibilities:
1> The AutoResponder itself is disabled (checkbox at the top)
2> The AutoResponder rule is disabled (checkbox at the left of the rule)
3> The rule you've written doesn't match the target request's URL.
Sharing a screenshot of Fiddler might help me tell you which problem you're encountering.
On the top of the list EricLaw gave in the previous answer, I add a new one:
You need to ensure your Fidler has the "Capturing Traffic" mode enabled. Either press F12 or go to "File" -> "Capture Traffic" and make sure you have a "Capturing.." icon on your left bottom corner.
I had a similar issue, and I solved it by enabling decryption of HTTPS traffic.
You can do this by going to Tools > Options > , then check Decrypt HTTPS Traffic
I had the same problem. I drag-dropped from the left, "main", window into the autoresponder so the "request matches..." column auto-populated. As a sanity check I unchecked "unmatched requests passthrough" to ensure that the match rule was indeed picking it up. If it hadn't nothing would appear in the main window at all. But it did appear so the rule was matching.
The issue with Fiddler is in the "then respond with..." column. Right-click for "Edit Response...", edit the response in the popup window of tabs, press Save, close the box.
When you retry your URL, your edited response isn't returned. Fiddler returns the original response. Even if you Edit Response again, it'll show what you typed in, but it never actually returns it.
To fix, you have to save the intended response to a file on your hard drive and edit it there.

Print page content

I just started playing with google chrome apps. I've searched the internet and haven't found the way to print the content of the windows. Tried using windows.print(), but nothing happened.
As far as I have read, the print() wont work since it is called in the background.html that does not have any content. How can I make the call at the correct place and send the content of the app to the printer?
Thank you in advance!
You're right that this can't be done through the Background page, since it is not rendered. What you'll need to do is inject a "content script" into the page you would like to print. The content script would contain the print command, and probably whatever would trigger the print command.
In a nutshell, "content scripts" are scripts that are injected into the pages a user browses. You can inject pretty much any JavaScript you like, and even inject entire JavaScript libraries like JQuery. More details can be found here:
https://developer.chrome.com/extensions/content_scripts.html
If you decide to use a popup window to trigger the print you can pass a message to the window you would like to print. Message passing is how the different components of an extension (background page, content script, popup) communicate. More info can be found here:
http://developer.chrome.com/extensions/messaging.html
Printing in apps is not yet supported, I believe. See
Issue 131279: async version of window.print()

Handling pop ups using selenium with perl

I want a solution for the following scenario:
In a page I am uploading an xml and while clicking on the upload button I am going to recieve an pop up for confirmation (I am able to detect this), after this again I am recieving an pop up which I am not able to detect (The page is still getting loaded in the browser ). Kindly help me to sort this out .
I have tried with many solutions for this like: get window ids,titles .
Thanks
You can you use -
$sel->get_confirmation()
This retrieves the message of a JavaScript confirmation dialog generated duringthe previous action. By default, the confirm function will return true, having the same effectas manually clicking OK. This can be changed by prior execution of thechooseCancelOnNextConfirmation command. If an confirmation is generatedbut you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript confirmations will NOT pop up a visibledialog.
NOTE: Selenium does NOT support JavaScript confirmations that aregenerated in a page's onload() event handler. In this case a visibledialog WILL be generated and Selenium will hang until you manually clickOK.
Returns the message of the most recent JavaScript confirmation dialog.
You should always refer to WWW::Selenium - Perl Client while working with perl and RC.
I have found what is the problem #amey ...I am tring to upload an file which is not actually not permitted due to some security issues with firefox... There was actually an work around for this
http://cakebaker.42dh.com/2006/03/29/file-upload-with-selenium/
.....Which will not work with latest Selenium RC with Firefox since firefox have removed the support for enablePrivilege
https://support.mozilla.org/en-US/questions/944433.
So it is a mandate to shift to WEBDRIVER it seems.............
http://git.erp5.org/gitweb/erp5.git/commitdiff/06898bbfae4f238b7e79ce05048646529216064e
Thanks for your support....
my solution was using the function:
$driver->execute_script("Events.invokeEvent('UserDetailPage:UserDetailScreen:UserDetailToolbarButtonSet:UserDetailToolbarButtons_DeleteUserButton_act', true);");
analyzing what the javascript code does when the Accept button was pressed. and executing that code in the function.