When ever launching the web-app in chrome browser using selenium webdriver, Geo-location(Geo Location) Pop up is coming on the top of the browser.
Due to which some of my location based Test Cases are getting failed.
How to handle these kind of scenarios using chromedriver?
"When ever launching the web-app in chrome browser using selenium webdriver,
Geo-location(Geo Location) Pop up is coming on the top of the browser."
in this case, u may try something like this:
#BeforeMethod
public void clearPopup() {
driver.navigate().refresh();
Thread.sleep(2000);//wait until the page is loaded.
//try to use explicit wait
try {
Alert alert = driver.switchTo().alert();
alert.dismiss();
} catch (NoAlertPresentException ex) {
//System.out.println("No alert for this test case.");
}
}
this method will run before all ur testcase and if any popup shows it will dismiss the alert.
I also have go through ur url. when i click on call geolocation api, a pop is shown. U can stop this kind of pop up by doing the followings:
-go to settings of chrome and click on advanced settings.
-than click on content settings under privacy.
-than u will see pop ups and location options.
form there choose what option u want. Choose
"Allow all sites to track ur physical location"
if u don't want to see the popup.
Related
Let's say I am currently at the following link:
"localhost/admin/test" when i do
window.open("/user/list/2034", "_blank")
it will appear like this:
localhost/admin/test/user/list/2034
what can i do to make it like this instead?
localhost/user/list/2034
I am assuming that windows should be window. If it really is windows then you have a custom object and need to show us what that is before we can answer your question.
The other point to note is that window.open will open a new window, regardless what you name it, so you don't need to use the _blank name. You only need to specify a name if you want to subsequently reuse that window (e.g. open another URL in the same other window).
When at http://localhost/admin/test, if you do:
window.open("/user/list/2034")
It will go to http://localhost/user/list/2034, unless...
window.open has been redefined somewhere. You can do console.log(window.open) and the console should say something like ƒ open() { [native code] } if it hasn't been redefined.
Your web server is responding to /user/list/2034 with a redirect to /admin/test/user/list/2034. The network tab in your developer console will show you the HTTP requests and responses where you can see if the web server is redirecting.
Your link really doesn't start with a / and you actually have window.open("user/list/2034")
You're viewing a cached version of the page with the above error in it, the source code is fixed but the browser hasn't loaded it. Try again in a private browsing window to see if it still happens.
You have some browser plug-in or extension interfering with your page. Try another browser/computer without the extensions and see if it still happens.
I am trying to use Dialog API of Office addin.
I can successfully open a Dialog box from my task pane by:
$scope.openDialog = function () {
Office.context.ui.displayDialogAsync('https://localhost:3000/home',
function (asyncResult) {
dialog = asyncResult.value;
dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
});
}
My Dialog box is a mean-stack site. I have added <script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script> in the index.html. And I tried to use Office.context.ui.messageParent(true);, it shows an error in console:
And I see in the doc that I don't understand quite well:
The Office JavaScript library is loaded in the page. (Like any page
that uses the Office JavaScript library, script for the page must
assign a method to the Office.initialize property, although it can be
an empty method. For details, see Initializing your add-in.)
I also tried to add Office.initialize = function () { }; in index.html, the error is still there, and processMessage of the task pane does not seem to receive anything.
So is there anything special I should do to my mean-stack site so that it could use messagePerent?
The console error will not introduce any bad effect to the dialog. We already fixed it internal. You can just ignore this error. Did you check whether office.context.ui.messageParent is null or undefined ? if it is not, then the dialog has been initialized successfully. Then it will be only something wrong with the postMessage method, what system and browser version are you using ?
1. If it is Win10 and latest version of IE, please make sure the dialog first page domain is same with the taskpane domain. Or you can use other browser to try it.
2. If it is Win7&8&8.1 and IE, then you can just try in other browser to see whether the messageParent api is work. We have already done a code change to fix the IE issue. It will be deployed to prod soon.
Is there a way to handle Cancel button on the Open in App pop up when I redirect from Safari/Chrome to AppStore?
The scenario is something like this: A user receives a message to download the app. It is a browser link. On that browser link check if it is an android or ios? If iOS redirect to App Store or otherwise.
This works seamlessly on android. But iOS on the other hand displays a pop-up to the user, weather to switch and open in another app.
Now my client requires me to handle the Cancel button.
So, could there be a way to handle this via JavaScript?
Code looks something like this:
if($rootScope.$device.Android()) {
window.location = appConfig.PLAYSTORE_LINK;
return;
}
if($rootScope.$device.iOS()) {
window.location = appConfig.APPSTORE_LINK;
return;
}
P.S.: Though, I believe it is an OS level pop-up. It might not be a possibility or a feasible solution to handle this pop-up.
You are correct: this is a user interface element controlled by Apple. You cannot programatically manipulate this alert.
I'm coding an Outlook Add-in.
I want to show a dialog message by using displayDialogAsync().
But when I use the method, the confirmation message is shown, before displaying a dialog (I attached a screenshot).
Are there any solutions for skipping this message?
screen shot : the message when a code calls displayDialogAsync()
・reference
https://dev.office.com/docs/add-ins/develop/dialog-api-in-office-add-ins
function openWindow()
{
var startAddress = 'https://localhost:44303/AppCompose/Sample/Sample.html';
Office.context.ui.displayDialogAsync(startAddress);
}
The message is necessary to prevent pop-up blockers. So no, there is no way to skip it if you use pop-up mode. However, if your page supports iframing you can pass the displayAsIframe=true parameter (see documentation); this mode doesn't show the extra confirmation because it is displayed as a floating div with an Iframe (as opposed to a new window).
Important: I see you are using the API in Office Online. Please be aware that we have not yet officially updated our documentation and samples to state that it's supported so you might see some bumps along the way. I expect everything will be in place by early next year.
In Outlook Web Access, use window.open() instead of the Dialog API. This will allow you to launch a child window without displaying this dialog. There are some caveats, though:
The URL of the window being launched must belong to the same domain as your add-in. Otherwise, you may see a popup blocked warning.
Firefox will show a popup blocked warning if window.open() is not called as a direct result of a user action. If your add-in's users may be using Firefox, just make sure that when launching a new window, that you're doing it directly within an onClick handler or something, not via a Promise or an async callback.
In Outlook desktop apps, the Dialog API works as expected, and in fact, using window.open() will always trigger a popup blocked warning.
Our add-in has logic similar to the following:
function launchDialog(url) {
if (/WebApp/.test(Office.context.mailbox.diagnostics.hostName)) {
window.open(url);
} else {
Office.context.ui.displayDialogAsync(url);
}
}
Hope this helps!
I am trying to Automate a login scenario of my project.
After Hitting the URL a POPUP Authentication window comes even before the page loads.
If we not pass that window we can't see the home page.
the problem is once the pop-up comes i can't inspect the element using firebug,its not letting me to click anywhere else.
i tries to handle the window but still the control is not going to the username and password text box.
i tried windowhandle,robot class but not working.
Please anybody can help??
here is the piece of code:-
Set<String> handles = driver.getWindowHandles(); // get all window handles
System.out.println(handles.size());
Iterator<String> iterator = handles.iterator();
while (iterator.hasNext()){
subWindowHandler = iterator.next();
}
driver.switchTo().window(subWindowHandler);
also the robot class:-
Robot rb = new Robot();
//Enter user name by ctrl-v
StringSelection username = new StringSelection("myusername");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(username, null);
Thread.sleep(2000);
river.switchTo().window(mainHandle);
rb.keyPress(KeyEvent.VK_A);
rb.keyRelease(KeyEvent.VK_A);
rb.keyPress(KeyEvent.VK_M);
rb.keyRelease(KeyEvent.VK_M);
rb.keyPress(KeyEvent.VK_CONTROL);
rb.keyPress(KeyEvent.VK_V);
rb.keyRelease(KeyEvent.VK_V);
rb.keyRelease(KeyEvent.VK_CONTROL);
//tab to password entry field
rb.keyPress(KeyEvent.VK_TAB);
rb.keyRelease(KeyEvent.VK_TAB);
Thread.sleep(2000);
//Enter password by ctrl-v
StringSelection pass = new StringSelection("password");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(pass, null);
rb.keyPress(KeyEvent.VK_CONTROL);
rb.keyPress(KeyEvent.VK_V);
rb.keyRelease(KeyEvent.VK_V);
rb.keyRelease(KeyEvent.VK_CONTROL);
//press enter
rb.keyPress(KeyEvent.VK_ENTER);
rb.keyRelease(KeyEvent.VK_ENTER);
//wait
Thread.sleep(5000);
You can do one thing. you can try it.
If we press ESC button then application stop processing many times.
after clicking on event use this below code:-
Robot r = new Robot();
r.keyPress(KeyEvent.VK_ESCAPE);
r.keyRelease(KeyEvent.VK_ESCAPE);
above code will press ESC for you. Now you can get the time to find the element.
Hope it will help you :)
Its not possible to automate the browser based authentication using Selenium.
If your authentication is http based then try opening the url using format - http://username:password#example.com/ instead of example.com.
If at all you still want to automate it then use third party plugins like AutoIt to accomplish it which works along with Selenium. AutoIt is used to automate windows based desktop applications including browsers. Here are few links that you can refer to -
Login to chrome using AutoIt
Handling Authentication using AutoIt
Use AutoIt with Selenium
Also you can use plugins for firefox which authenticates the popups automatically, when you open the url. But this is a manual setup and you have to perform authentication once so that the plugin remembers it. Here's one of them.
Hope this helps.