Selenium IDE simulate press ENTER for javascript configmation box - firefox-addon

I am looking for allready for hours how to do this. So don't tell me to use search function. I know there are many things related.
There is many stuff on the internet and here, but no one works for me.
And I need a solution for Selenium IDE or something intergrated with it (if there is anything). Not RC and not WebDriver etc.
I need to simulate a key for an JavaScript confirmation popup, which has "OK" and "Cancel" buttons.
The problem is that I cannot select anything.
Popup appears when the site is opened. The Website itself is visible in the background, but no element can be selected (Firebug shows nothing as well, empty html(?)).
If I press ENTER key the confirmation box disappear (so it works fine manually).
This example seems good, but I can't find any interface in Selenium IDE to do this:
driver.switchTo().alert().accept();
(from Click in OK button inside an Alert (Selenium IDE))
I have only the following pattern:
Or write the test in html, which uses the "Command", "Target", "Value" pattern.
Appreciate any help.
EDIT1:
With the link provided by Janesh Kodikara
I have found that my problem is:
Selenium IDE will not be able to handle alerts that are within the page's onload() function. It will only be able to handle alerts that are generated after the page has completely loaded.
There is no "onload" function in my website, but the script part which creates the alert is inside html which is called with page (not in any function). This must be the same as "onload", because the alert comes immediately when the website is opened.

Once you have a confirmation box, you must consume it (Click OK or Cancel button)
You can use "chooseOkOnNextConfirmation" command to instruct Selenium IDE to simulate clicking OK button.
See http://www.guru99.com/enhancing-selenium-ide-script.html for more details.
You will not see the Javascript popup when IDE script is run.

Selenium IDE
Command : runScript
target : {window.onbeforeunload=function(e){};}
Command :click
target : xpath of button.
This will work fine but you are not able to see popup.

Related

Visual Studio 2022 find the next line of code to execute

I am learning a new ASP.NET MVC app that uses some approaches I am not used to / familiar with. Without having to deal with the client side scripts (because there appear to be over a thousand), I want Visual Studio to go into break mode / stop at the first line of code executed on the server.
Is there a way to do that?
For example, I click a button in the web site that run a script that shows a dialog box (I don't believe any server code has executed at this point in this series of events). Then I fill in some fields and click a button in the dialog box that I know sends data back to the server. I want the sever to stop at the first line of code it attempts to execute as a result of the button being clicked.
I thought you used to be able to put the app in Break mode, then you could use the Step Into button to take you to the next line of code but this no longer seems to work.
Any ideas?
You can use my Runtime Flow tool to find out what code is executed on the server when you click a button in the web site. Though you need to manually configure Runtime Flow to monitor your web application as described here https://vlasovstudio.com/runtime-flow/documentation/quick_start.html

Can you use AddEventListener with CEF4Delphi?

I am using Delphi XE2 and Chromium CEF4Delphi. I am trying to use a web page via the TChromiumWindow component and would like to detect when an element is selected / clicked.
I saw this post..
Delphi Chromium - launch a command in Delphi application when button in web page is clicked by user
Unfortunately, I cant find the function AddEventListenerProc in the CEF4Delphi library. Neither can I find an alternative way to monitor a button / element click.
I would like to use the TChromiumWindow component to act as a "fron-end" to my app and would like to monitor user button clicks etc.
Can anyone help please ? I did try the developer forum but I dont see much activity there and was unable to register.
Many thanks..
The DCEF3 project has a group here : https://groups.google.com/forum/#!forum/delphichromiumembedded
But the CEF4Delphi and OldCEF4Delphi projects have a developers forum here :
https://www.briskbard.com/forum/
That forum has new posts almost every day and I try to answer them as soon as I can, usually in less than 24 hours.
If you have problems creating an account just send me a message and I'll activate your account manually.
The link you posted is very old and many things have changed in CEF since 2012.
There are several ways to detect when a HTML element has been selected, clicked, etc.
You can use a JavaScript event like "onclick" that calls a custom JavaScript extension. That extension would send a process message to the browser process to notify that the user clicked that element.
You can also use the GlobalCEFApp.OnFocusedNodeChanged that is triggered when an HTML element has been focused. This event is executed in the "render" process so you will also need to send a process message to the main browser process that the focused element has changed.
Use the JSRTTIExtension or the JSExtension demos as a template for your app.
They show you how to set a "mouseover" event that calls the "myextension.mouseover" function defined in a custom JS extension. The myextension.mouseover function executes Delphi code and sends a process message to the main browser process with some HTML information that is shown in the status bar.
They also have an example for a "MutationObserver" that calls a generic "myextension.sendresulttobrowser" function in the JS extension that sends the "value" attribute to the browser process.
Build the demo and right-click on the web page when it's fully loaded. Then select the "Set mouseover event" or "Add mutation observer" options to test what I described.

RichTextBox in .net giving weird behaviour in Windows7 but working fine in WindowsXP

I have an application in which view and edit of a script(which is a .txt file) has to be performed. I am using a RichTextBox on .net platform for this. When user wants to view a script, I just copy the script in my richtext box with WordWrap true. But when user has to edit it, I have to show it in a single line. This does not require the word wrap property to be true.
But this is working fine on WindowsXP but when viewed on Windows 7 PC, on editing, the script is truncated. If user clicks anywhere on the dialog box which has richtextbox, the whole script can be seen. This happens each time when user selects to Edit it.
Also, If I do a remote desktop to Windows7 PC, the script can be seen properly at once only when editscript is done.
Can someone please help in this?
Can this be graphic card issue? I have checked changing the resolution but it didn't work

Google Chrome Extension: Print the page silently

I'm developing an internal Google Chrome Extension that needs a way to initiate print the current page to the printer. I do not want the default Print dialog to come up (so, javascript:window.print() is out of question).
As far as I understand, this is not possible just with the JS + HTML plug-in, so I'm also open to using the NPAPI plugin also (with a dummy mime-type). And I'm concerned for Windows platform only.
I'm also open for various hacks / workarounds if possible, though a standard solution would be nice.
If you think this is not possible, let me know if you know any feature request logged for it?
Any suggestions/clarifications are welcome..
In chrome (v18+) we have the --kiosk --kiosk-printing switches. One can print automatically to default printer without print confirmation.
You can see it from this video http://www.youtube.com/watch?v=D6UHjuvI7IE
Since NPAPI allows you to create native C++ plugins that you can interact with through an object tag (which you can use from an extension), that would probably be the way to do it.
The tricky bit is that I don't know of a good way to get the bits for printing the page. The only person I know of who has done something similar to this actually got the window handle for the browser (available through NPAPI) and scraped the bits off of it to print that way, but that won't take into account print stylesheets or anything. You could also try using automation events to try to control the print dialog, but I have no idea if that would work or not.
By design, the browsers try not to let you do something like this, as it could open some serious vulnerabilities if any website could just start printing things to your printer without confirmation...
Anyway, if you find a way to do it with C++ you can use FireBreath to ease the creation of the NPAPI plugin.
There are various extensions that take snapshots of the current web page (for example, this one); you could adapt one to send the image to a printer via an NPAPI plugin.
I've recently been looking for a similar ability, and it seems like it would be quite possible using Chrome's new native messaging api.
https://developer.chrome.com/extensions/nativeMessaging
There are plenty of examples of this with C#, but here is one quick example of troubleshooting Chrome native messaging with a basic C# application
Native messaging from chrome extension to native host written in C#
I realize this may be a day late and a dollar short, but in case anyone else comes across this question, this is the solution that worked for me. From inside a C# app, you can directly print to installed printers using the PrintDocument class. If you figured out a way to get the page image, this would be far easier than using firebreath or NPAPI.
Disable print preview in Google Chrome on Mac
Quit Google Chrome
Launch Terminal on your Mac. (Search “Terminal” using the Search box)
Type defaults write com.google.Chrome DisablePrintPreview -bool true
Close Terminal and open Google Chrome
Disable print preview in Google Chrome on Windows
Close Google Chrome
From your desktop, right click Google Chrome
Click Properties
In the dialog box, add ‘ –disable-print-preview‘ at the end of the Target field sans the apostrophe (make sure to include the space before –)
Click Apply
Disable print preview in Firefox on Mac
In the address bar type “about:config” and press Enter.
Right click on the page, hover over ‘New’ and click on ‘Boolean’
Type ‘print.always_print_silent’ as the preference name and click ‘OK’
Click on ‘true’ and click ‘OK’.
Close the about:config window.
Disable print preview in Firefox on Windows
In the address bar type “about:config” and press Enter.
Right click on the page, hover over ‘New’ and click on ‘Boolean’ Type
‘print.always_print_silent‘ as the preference name and click ‘OK’
Click on ‘true’ and click ‘OK’.
Close the about:config window.
https://support.dryfta.com/how-to-disable-print-preview-in-chrome-firefox-on-windows-mac/

Using Toolbar to submit SAS code from Editor

When submitting SAS code via the SAS Toolbar (eg cmjohns response) the compiler knows that the code is being "DM'd" and will not run certain code (eg %window).
Is there a way to trick SAS into believing that code submitted from the Toolbar is coming from the Editor, therefore allowing interfaces (using %window) to be triggered via point and click?
It isn't super clean, but this will do it. The only downside is a program editor window will be open after it runs. There's probably a way to close it when it's done but I don't know what that is off hand.
pgm; clear;include "C:\path\code.sas"; submit;
Basically, this says to open a new program editor window and make sure no other code is in it, then include the contents of code.sas into the editor, then submit all the code that's in the program editor.
As a side note, in addition to a toolbar button, I think you could map a function key to a command like this as well. Press F9 to pull up the current mapping. There is a limit to the length of the command mapped to a key though so no long paths.

Resources