How to enable popup blocking settings in firefox or chrome using webdriver script? - popup

I tried opening hdfc.com site using Webdriver. It gives a image popup that blocks clicking apply online link. How to handle through the webdriver script? how to enable Block popup windows checkbox in firefox using webdriver scripting?

You should use WindowHandles and ignore the pop-up windows. That way the driver will stay on the original window only .
Set<String> handle= driver.getWindowHandles();
driver.switchTo().window("windowName");
This way even if you are not able to block the pop-ups , driver will ignore the existence of the other pop-ups and execute the script

Related

ElementNotInteractableError: element not interactable in selenium-side-runner but not in selenium IDE

I am running a Selenium .side file in selenium-side-runner and get
ElementNotInteractableError: element not interactable
(Session info: chrome=83.0.4103.61)
Same browser version, with selenium IDE runs fine.
How can I debug that?
Even the session closes after the selenium-side-runner test so I do not have a chance to look at the current state of the website.
I did not find an option like "leave session open after failure".
It looks like the IDE does a better job at implicit waiting than the side-runner. As a workaround I added pause statements to wait for the elements which are dynamically loaded.
See also https://groups.google.com/forum/m/#!topic/selenium-users/XzDQ95w9OVg
I think this is the closest issue https://github.com/SeleniumHQ/selenium-ide/issues/643

Print text with clickable link in console or terminal in Perl [duplicate]

How do I display a hyperlink (weblink) in hudson/jenkins build output console?
What I'm trying to achieve is, during a hudson/jenkins build based on certain condition, I would like to display a hyperlink.
When a user click on that link, it should open a new browser window and show the page.
Is there a plugin to do this? Any suggestions please?
When using a (system) groovy script or Jenkins job pipeline (without sandbox) you may want to try e.g.:
import hudson.console.ModelHyperlinkNote
println hudson.console.ModelHyperlinkNote.encodeTo('http://example.com', 'example')
Please find the full API of hudson.console.ModelHyperlinkNote here:
http://javadoc.jenkins-ci.org/hudson/console/ModelHyperlinkNote.html
If you enter, for example:
echo 'http://example.com'
in a Build step Execute shell → Command the address will be hyperlinked in the Console Output, though not with target="_blank". But middle-clicking on it opens it in a new tab or window – depending on your browser preferences.

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.

Can't see dynamically loaded code in Chrome Developer Tools 22

When I dynamically load a snippet of html containing javascript via AJAX, I cannot see that content in the source tab in the developer tools window in Chrome 22.0.1229.94. Tellingly, I went here
https://developers.google.com/chrome-developer-tools/docs/scripts-breakpoints#js_dynamic
This page shows an example developer tools window which is out of date. There is a button on the page to load a dynamic script and it does not show up in the source tab when you do.
As a work-around, I have found that adding
debugger;
to the script and reloading it will cause it to pause in the dynamically loaded code, but unfortunately, all the line numbers are greyed out and you can't set any breakpoints within the debugger.
Am I missing something here or what?
Thanks,
Rob
When you use a library or javascript code that you have loaded it dynamically, you can use the phrase
//# sourceURL=foo.js
at the beginning of your javascript code that foo.js is the name that will be assigned it. debugger will show it with that name.
This is true in chrome, and I think in firebug too.
In this case you can place a breakpoint in the dynamically loaded javascript code.
Possible duplicate of:
Is possible to debug dynamic loading JavaScript by some debugger like WebKit, FireBug or IE8 Developer Tool?
Don't know if this works or not in chrome (This definitely doesn't work for me now, may be in the past).
//# sourceURL=foo.js
Working Solution
For your dynamically loaded script via ajax to appear in your chrome source tool, you need to add the following line at the start or end (I prefer) location of your script file:
//# sourceURL=foo.js
And your script with name foo.js will appear at the left pane of source tab under (no domain) dropdown
->localhost
-- source/src
->(no domain)
-- foo.js
Alternatively you can add the below line in your script anywhere between the scripts.
debugger;
In chrome, you can use " debugger; " statement to break at a statement when debugger panel is open. Chrome will simply ignore this if the debugger panel is closed.
This will help stop your script in debugging mode and you will see your script in source (debugging) panel with name like VM****.
Hope this helps.
You can use //# sourceURL. Chrome doesn't seem to be supporting //# sourceURL for inline scripts. However, it does work on eval expressions. This article gives more details about naming eval blocks and naming of any anonymous functions in your code.
Instead of using eval, you can try embedding a script tag or JSONP may be.
Varunkumar Nagarajan
for me it happened on nodejs project.
i restarted server and open in new tab my app and tada!..
Alternatively, to fix this problem you can open developer tool in a seprate window by clicking the icon. Now reload your script, and it will shown in script tab as expected. I know this is not a solution but a work arround.

Does selenium support IE with google frame add on installed on it?

Selenium is able to load Chrome Frame pages. The problem is that once you load the page in IE with Chrome Frame plugin, the tag appears as empty. Selenium tries to identify elements using the DOM structure, but the way IE and Chrome Frame plugin works, rendering
and DOM tree are taken over by the Chromium code and IE gets an empty DOM.
So i guess, selenium doesn't support IE with google frame add-on installed on it?
Has anyone worked around this problem?
Thanks
This question has been asked and answered on the Selenium user's mailing list. The IE driver doesn't work with the Google Chrome Frame add-on, and there are no plans to implement support for it to work with the Chrome Frame add-on. Either you want to test the operation of your website under Chrome (in which case you should use the ChromeDriver), or you want to test it under IE (in which case you should use the IE driver). If you can point to a specific case where using the website with the Chrome Frame add-on behaves differently than the way it behaves with the Chrome standalone browser, you might be able to make a case to revisit the issue. Furthermore, remember that Selenium is an Open Source project, and you are welcome to make changes and submit patches to the code at any time.
Watir WebDriver has the same issue.
Selenium core, the part that loads in the target browser and executes tests does work and can be run independently. So, if you have a Selenium test suite in HTML form, it can be run in GCF using the following steps:
Configure a web server to opt all URLs into chrome frame using HTTP header as described here: http://www.chromium.org/developers/how-tos/chrome-frame-getting-started#TOC-Making-Your-Pages-Work-With-Google-
Host your test suite under '/tests' folder on this web server. Lets say the suite is my_test_suite.html.
Host the selenium core folder as the '/core' on the server
Now restart the server.
Run the suite with this URL: http:///core/TestRunner.html?test=tests/my_test_suite.html&auto=true