No Alert Found using Chrome Driver - selenium

Using ChromeDriver 2.14, selenium server 2.47.1 and Chrome 45. I am attempting to handle a basic authentication prompt. I have tried the following code to try and resolve this.
var wait = new OpenQA.Selenium.Support.UI.WebDriverWait(Driver.Value, new TimeSpan(0,0,60)).Until(OpenQA.Selenium.Support.UI.ExpectedConditions.AlertIsPresent());
Driver.Value.SwitchTo().Alert().Dismiss();
And this
Driver.Value.SwitchTo().Alert().SetAuthenticationCredentials("test", "test");
and this
while (true)
{
try
{
Driver.Value.SwitchTo().Alert().SetAuthenticationCredentials("test", "test");
break; //this is brute force I know
}
catch
{
Thread.Sleep(100);
}
}
No luck, they all throw a "no alert found" exception. We would switch to firefox, but it is an internal application and we only support IE or Chrome.

I didn't find a way to use the authentication options inside Selenium with the basic authtication prompt. Instead I found that if you run fiddler in the background, you can have it auto-authenticate for you when prompted based on a specific site. Then the popup never shows up and your Selenium scripts run just fine.
Auto http authenticate traffic for a specific site with fiddler

Related

How can I debug a websocket connection?

When running within a testcafe test, upon loading an app that tries to connect to a websocket, I receive an error in the console of "Connection closed before receiving a handshake response"
This prevents most of the app from working.
How can I get additional information about what the final request that testcafe is making after url-rewriting? I'd like to see exactly what url & headers it's sending to try to connect.
Simple example:
import { ClientFunction, Selector } from "testcafe";
fixture`Getting Started`.page("https://torus.qa.argos.education/session/new");
test("Example error", async (t) => {
await t.debug();
});
I've tried chrome with both non ssl and self signed certificate mode, and also tried disabling web security. Firefox gives the same error.
We released a new TestCafe version (v2.3.0), which includes experimental proxyless mode. This mode uses native browser automation. In Proxyless mode, a few issues are already fixed. This issue should also be fixed in Proxyless mode.
Unfortunately, I was not able to test your web site since the URL you shared is no longer available. Would you please check if your sample is working correctly in v2.3.0 with experimental proxyless mode enabled?
This option is available in all interfaces:
// Command-line
testcafe chrome tests --experimental-proxyless
// Programmatic
const testcafe = await createTestCafe({ experimentalProxyless: true });
// Configuration file
{
"experimentalProxyless": "true"
}
Please keep in mind that this mode is still experimental and is implemented only in Google Chrome. It will not work correctly if you run tests in a non-Chrome browser or in a combination of other browsers.

Chromedriver - IE Tab permission not granted

I am testing web application. In my test I check client data. For use this test I need IE Tab in chromedriver. I'm initializing chromedriver with IETab correctly. After that page is display with below popup
With popup in console I see below log:
Uncaught IETABAPI Error: Permission not granted. You must call window.ietab.requestAccess to use the IE Tab Api.
I clik Allow and nothing's gonna happen. Correctly test should opening new bookmark in chromedriver. Below my code which is executing chromedriver with IETab.
default void ChromeExtensionIETab() {
ChromeOptions options = new ChromeOptions();
options.addExtensions(new File("C:\\Users\\user\\Dysk Google\\all\\testowanie\\chromedriver_win32\\extension_12_4_4_1.crx"));
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
options.addArguments("--use-fake-ui-for-media-stream");
System.setProperty("webdriver.chrome.driver", "C:\\Users\\user\\Dysk Google\\all\\testowanie\\chromedriver_win32\\chromedriver.exe");
setDriver(new ChromeDriver(options));
getDriver().get("https://api-test/");
getDriver().manage().window().maximize();
getDriver().manage().timeouts().implicitlyWait(18, TimeUnit.SECONDS);
}
Can someone explain me what should I do?
The Enterprise version of IE Tab includes permissions that would otherwise have to be manually enabled by your end users. Read more here.
If IE Tab is installed:
Click here to allow IE Tab to access https:// URLs and file downloads
Enterprise customers please contact us at support#ietab.net to discover how to deploy these settings automatically.
What we don't see is the web page that you are "driving".
The pop-up you are seeing is from the IE Tab api which must first call window.ietab.requestAccess and wait for the result before calling window.ietab.openWithIETab.
The error you are seeing is because the page called window.ietab.openWithIETab without waiting for a response form requestAccess.
So the web-page is probably calling both calls without waiting for the result from requestAccess, perhaps because the developer had already allowed access so they aren't aware that this pop-up is showing any more.

Cant open https web using Slimerjs, casperjs, phantomjs

This is first time i cant open website using headless browser such: phantomjs, slimerjs or casperjs. I just want to open website. I just create very basic script to open the website and take screenshot. but 3 (three) of them give me blank picture.
i try using:
--debug=true
--ssl-protocol=TLSv1.2 (i try each of available protocol)
--ignore-ssl-errors=true
Here my script:
Slimerjs
var page = require("webpage").create();
page.open("https://domain/")
.then(function(status){
if (status == "success") {
page.viewportSize = { width:1024, height:768 };
page.render('screenshot.png');
}
else {
console.log("Sorry, the page is not loaded");
}
page.close();
phantom.exit();
});
phantomjs
var page = require('webpage').create();
page.open('https://domain/', function() {
page.render('screenshot.png');
phantom.exit();
});
casperjs
var casper = require('casper').create({
viewportSize: {width: 950, height: 950}
});
casper.start('https://domain/', function() {
this.capture('screenshot.png');
});
casper.run();
I even try to use screen capture service to know if they can open or not. But all of them give me nothing too.
is there i miss something?
The issue is not because of PhantomJS as such. The site you are checking is protected by a F5 network protection
https://devcentral.f5.com/articles/these-are-not-the-scrapes-youre-looking-for-session-anomalies
So its not that the page doesn't load. It is that the protection mechanism detects that PhantomJS is a bot based on checks they have implemented
The easiest of fixes is to use Chrome instead of PhantomJS. Else it means a decent amount of investigation time
Some similar unanswered/answered question in the past
Selenium and PhantomJS : webpage thinks Javascript is disabled
PhantomJS get no real content running on AWS EC2 CentOS 6
file_get_contents while bypassing javascript detection
Python POST Request Not Returning HTML, Requesting JavaScript Be Enabled
I will update this post with more details that I find. But my experience says, go with what works instead of wasting time on such sites which don't work under PhantomJS
Update-1
I have tried to import the browser cookies to PhantomJS and it still won't work. Which means there is some hard checks
I experienced this issue with phantomJS and the following service args resolved it:
--ignore-ssl-errors=true
--ssl-protocol=any
--web-security=false
--proxy-type=None
Can't help you with casperJS and slimerJS, and don't know exactly why this worked.

Catch the closing event of the chrome browser using chrome driver

I am doing the automation in an application for some web pages in the vb.net using the chrome driver.
During the application operation here is a chance that chrome may close before completion of automation process (user may close or chrome may crash).
Now my requirement is that if the chrome is closed by the user while automation is running, the application needs to know that a close event in chrome is raised by the user and the application needs give a Yes/No message with the custom text to confirm the action of the user.
I searched this for some time on the internet and found nothing. Please provide the way to catch the closing event of the chrome browser in vb.net using the chrome driver.
Not sure I quite understand the question, but can you use the window.onbeforeunload approach?
e.g. See W3Schools
$(document).ready(function () {
window.onbeforeunload = function () {
//your code here
};
});

selenium rc on one linux server

I want to have selenium to run on one server like ubuntu, centos and to run all browsers check on that linux (centos or ubuntu server). So check of ie6, ie7, ie8, ie9, chrome, firefox etc.
But then I think this is not possible, because for ie we need windows machine.
Or if we remove the ie and only want to test on chrome and firefox, can we do that on selenium rc on ubuntu or centos? Then I think on that server version I need to install firefox.
I think the main thing is that I don't get how the selenium server can work with actually not having browser installed or it can't?
Can anyone give me some instruction on this, I did read some documentation and nice tutorials, but this is not very clear to me.
Selenium Server is just an application that can send commands to web browsers. But, of course, you need a browser for that. If there's no browser and you write your tests in Selenium 2 (WebDriver), you can use HtmlUnitDriver (JavaDoc) which is inbuilt and doesn't actually open any browser. You could have read about it as "the in memory browser".
You could also check for presence of the browser by possibly doing something in the way of
WebDriver driver;
try {
driver = new InternetExplorerDriver();
catch (WebDriverException e) {
System.out.print("IE not found.");
try {
driver = new FirefoxDriver();
} catch (WebDriverException e) {
System.out.print("FF not found.");
}
// etc.
}