Stop Chrome in headless mode from logging - selenium

I'm using Python/Selenium/ChromeDriver/Chrome to scrape a website and it works fine but, especially in headless mode, I'm getting lots of logs such as those below. How do I stop these?
DevTools listening on ws://127.0.0.1...
[0323/120327.827:INFO:CONSOLE(0)] "The SSL certificate used to load...
[0323/120330.441:WARNING:spdy_session.cc(2921)] Received HEADERS for invalid...
[0323/120353.366:WARNING:render_frame_host_impl.cc(2750)] OnDidStopLoading was called twice.
[0323/120356.054:INFO:CONSOLE(0)] "Refused to execute script from...

Related

Testcafe caught in page reload loop

I have a set of Testcafe tests for our application, which since recently fails to run in some of our environments. The test only opens the browser, loads the start page specified in the fixture (or navigated to in within the test) and then only appears to continuously reload the page without proceeding with the test. This happening across all browsers (Chrome, Firefox, Edge) and different versions of NodeJs and Testcafe on Windows 10.
After enabling debug logging I found this message repeatedly in the log:
{
cmd: 'wait-for-file-download',
sessionId: '0X_DqYtz0'
}
The browser console also showed two page resources/scripts that failed to load with net::ERR_FAILED errors due to violating the Content Security Policy, so I assume that these might cause the problems. However it does not seem to have any impact on manual page interaction or automated test using other frameworks like PyTest.
While we are investigating on the conflicting resources, is there anything I can do in Testcafe to bypass the issue and allow the tests to run? Or alternatively is there a way to fail a Testcafe test when encountering this issue instead of reloading and possibly eventually timing out?

Phantomjs - Silent Browser

I was using Phantomjs driver for execution of my Application test scenario.
In the Recent update, they have implemented individual certificates to each machines, so once I enter my application URL and hit enter_key, the URL is redirected to an internal server and I need to provide the Userid and Password to Log in.
This Scenario works well in chromedriver but when i'm using phantomjs, the elements are not getting recognized.
I tried to take the screenshots but only blank image came in the screenshot.

Phantom won't open a url that is accessible (but will open it with fiddler running)

I have a very simple phantom script that pretty much just opens a url and dumps the html to console (not actually, but I've narrowed the problem down to this):
page.open op.url, (status) ->
console.log "opened #{op.url}"
console.log page.evaluate -> document.all[0].outerHTML
phantom.exit()
When the url is https://latestcommit-negotiate-demo.owex.com phantomjs just hangs and never invokes the page.open callback. The site definitely exists and I can hit its login page in any of a dozen different ways but not with phantom!
What's especially bizarre is that I want to see whats going on over the wire - so I open up fiddler and...it starts working. As long as fiddler is open my script works great. The second I close it, it hangs on page.open again.
This is phantom 1.9.7 and I'm invoking it with the --ignore-ssl-errors=true flag.
Short of "something something ssl?" I'm at the limit of my knowledge. What could be causing this?
The solution was that our server was not doing https via sslv2 but (surprisingly) via tlsv1. Fiddler was unwrapping the https envelope and rewrapping it with ssl. Adding a --ssl-protocol=any flag solved the issue.

browserstack requesting localhost:45691

Anyone any idea why browserstack might be constantly requesting localhost:45691. When I open browserstack in Chrome I get this request continuously.
XMLHttpRequest cannot load localhost:45691. Origin http://www.browserstack.com is not allowed by Access-Control-Allow-Origin.
In FF its showing a JS file causing the issue
localhost:45691/
http://www.browserstack.com/assets/bsjs.js?1376347645
Anyone having this issue? I even sent a report to browser stack 3 days ago and nothing either. This is driving me crazy.
BrowserStack provides a feature of Local Testing via Command Line Tunnel. To check if tunnel is connected or not, their JavaScript(JS) tries to talk to a http server which runs on port 45691 inside BrowserStackTunnel.jar.
When you don't have this Command Line Tunnel set, then the JS gets these errors, which turns to 200 OK response as soon as tunnel gets connected.

How do I detect that SSL is broken on a page, using Selenium

We have pages where we occasionally see compromised SSL certificate because of third party scripts that load non HTTPS resources (Initially they're fine but they occasionally change). We would like to test those pages for broken SSL every day.
We have tried one approach, attempting to catch a pop-up message that would indicate that we have insecure content on the page. However, we have been unsuccessful in simulating the pop-up message through selenium. It appears that selenium has automatically disabled any popups. While we have identified a Selenium method to disable the suppression of the pop-ups(disable-popup-handler) but we have not been able to successfully see the popup even using this method.
Has anyone found a way to detect broken SSL pages using Selenium?
You need to load a browser profile (with WebDriver) that doesn't have the setting for popup blocker enabled (using the Profile class and giving it the right properties). Then, you will get the Windows popup message concerning the SSL cert. If , for some reason, you cannot control the popup using WebDriver (because its limited to Action control only within the browser content window) then you can use Sikuli API to handle the dialog and export the cert to the "Downloads" dir and then copy the file to expected location for inspection. Unfortunately, if you use Sikuli, that will make your automation script sequential and not work via a RemoteWebDriver grid server and so you wont be able to run parallel tests. Hopfully, WebDriver gives you access to the dialog and so you will be able to run with RemoteWebDriver because that is the best way to go when running scripts, even if you run a browser locally.