How to connect to firefox instance with debugger port? - selenium

I am trying to do remote debugging on a Firefox instance similarly to how I would do it in Chrome:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
If I start Chrome with this parameter, I can then inspect pages from another Chrome instance by navigating to localhost:9222
I am trying to do the same with Firefox:
Set "enable browser chrome and add-on debugging toolboxes" and "enable remote debugging" options to true
opened firefox with the following parameter:
"C:\Program Files\Mozilla Firefox\firefox.exe" -start-debugger-server 1234
Despite this, when I navigate to localhost:1234, the following happens:
I get multiple popups, that tell me there is an incoming request to Firefox
Even when I click okay, nothing seems to happen
localhost:1234 gives "refused to connect" error

Firefox has more debug functionality than chrome/chromium and to access those you need to:
Goto about:debugging
( Can be found in GUI under: triple-bar Button[≡] > Web Developer > Remote Debugging )
Enter your host Network Location and click Add
Click on your debugging instance on the right side.
Debug whatever you wanna debug(Tabs, Extensions or Processes etc.)

Related

Initializing Chrome with --unsafely-treat-insecure-origin-as-secure=<domain> doesn't enable the chrome flag

I'm looking to write some browser automated tests with chrome + chromedriver in a docker-compose network where localhost isn't an option and one of the features can only function within a secure context (https or localhost). Chrome seems to have a feature flag "Insecure origins treated as secure" to get around this by adding the chromedriver argument --unsafely-treat-insecure-origin-as-secure=. When i add this arg, it adds the domain in chrome://flags/#unsafely-treat-insecure-origin-as-secure but the feature is still marked as disabled. Is there something I can do here to also enable the feature?
I've noticed in chrome://version that when the feature is enabled and i relaunch chrome manually, it's present at the end of the "Command Line" section resembling
--flag-switches-begin --unsafely-treat-insecure-origin-as-secure=http:// --flag-switches-end
But when it's disabled, it's just
--flag-switches-begin --flag-switches-end

debugging chrome remotely - doesn't open websocket

Im running chrome headless through chromedriver and selenium via python.
I've run into the following issue both on Mac and Linux.
Im starting chrome as follows:
if self.headless:
options.headless = True
options.add_argument("--headless")
if self.debug_port:
logging.info(f"Setting up remote debugging on port {self.debug_port}")
options.add_argument(f"--remote-debugging-port={self.debug_port}")
options.add_argument(f"--remote-debugging-address=0.0.0.0")
If I connect to http://localhost:9222 from another headed instance of chrome I can see the list of sessions and connect to it seamlessly. At which point i have a window opened up with a screencast of the remote session and the dev console.
Here's that successful example:
When I connect to http://192.168.1.194:9222 I get the list of sessions just fine and upon selecting one the dev console opens but it doesn't start the websocket connection to ws://192.168.1.194 so the screencast and remote debugging capabilities are not available.
Here's that failed example:
I've captured har files and uploaded them here if you want to take a look
Using the following steps I was able to debug remotely. However the screencast functionality did not work. Ultimately that's what I needed so this is only a 50% solution in my case.
So, as noted above in the comments, what's blocking remote debugging from working is that the chrome debugger links out to https://chrome-devtools-frontend.appspot.com/..... and passes a value of ws://192.168.1.194 for the websocket parameter. Any browser will inherently block this, based on it being mixed content - i.e: https + ws
What's needed here is to run the chrome dev tools frontend on a http server
and direct your chrome instance to that server instead of the appspot instance.
Solution Steps
1 Install depot_tools (pre-requisite for building)
https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
2 Checkout the devtools-frontend repo
https://github.com/ChromeDevTools/devtools-frontend/blob/master/docs/workflows.md#checking-out-source
3 Build chrome devtools frontend
https://github.com/ChromeDevTools/devtools-frontend/blob/master/docs/workflows.md#build
4 Start the devtools-frontend http server
https://github.com/ChromeDevTools/devtools-frontend/blob/master/docs/workflows.md#running-in-hosted-mode
5 Run 2 instances of chrome and use one to debug the other
5.1 Start first instance of chrome headless
...with remote debugging enabled. See the python way in the question above or do it from the command line with the same arguments
5.2 Start a second instance of chrome
...using a different user data dir --user-data-dir=<some-path>
5.3 Navigate to http://192.168.1.194:9222
Use whatever the IP address of the first chrome instance is and the port that you chose.
5.4 Create a link to the local dev server
The 2nd instance of chrome will now be showing you links to debug each of the open tabs of the 1st instance. However the links will still to go https://chrome-devtools-frontend.appspot.com/..... You'll need to copy n paste the link you want and replace the hostname with the hostname of the devtools frontend that you started in step 4
Walla!!
If you figure out how to get the screencast working please comment below! 🙏
N.B:
I also tried using the npm run server command in the devtools frontend but for some reason that server didn't work at all ¯\_(ツ)_/¯

How to run test in IE browser using OxygenHQ?

I want to run a simple test using OxygenHQ, of opening wikipedia and then search for hello world. The script written is working fine for Chrome and Firefox but in case of IE mutiple windows are opening without the page and then it fails eventually.
Is there any way to fix this? I went through the docs provided at http://docs.oxygenhq.org/guide-web-intro.html but could not get a concrete answer on why this is only happening for IE. Here is a console output and screenshot for reference.
Console Output :
Initializing...
Starting iteration #1
UNKNOWN_ERROR - undefined: args[0].endsWith is not a function at line 1Test finished with status --> FAILED
Details:
Browser: Internet Explorer
Version: 11.535.18362.0
OS: Windows 10
This might be connected to your internet settings
make sure that the IE screen size is 100%
make sure all Internet options in Security Tab (Internet, Local Internet etc') are either with the Enable protected mode on or off (should be the same for all)
see picture
Have a look again at the Oxygen web site, it has had a major facelift and a lot of new content

Unable to perform activities on edge after opening the browser

System.setProperty("webdriver.edge.driver","F:\\VW_MU_Util\\MicrosoftWebDriver.exe");
WebDriver driver = new EdgeDriver();
This is opening the edge browser however I cant go ahead since i'm getting error as:
org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)
I tried to change the IE security settings but its opening the IE browser which i dont want to.
Make sure you have initiate correct Edge Driver, as according to your OS version.
Ref link : https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Steps :
Trace Build version:
Download correct version of Driver:
Once it finished, Verify it with demo project without any project capabilities. If it run successfully on sample project, It might cause browser capability with Selenium Browser.

Selenium Firefox - Browser is under remote control

I am using Firefox 55.0.2 (64-bit) with selenium. The code works fine, however I see an icon in Firefox saying Browser is under remote control and the URL is highlighted in orange as shown in below screen shot.
Is there a way to disable this message in Firefox?
You wouldn't get that in the previous versions of firefox (version 45 or below). Its just an update and cannot be disabled. Even google chrome shows a message(chrome is autmated by a software). or you could just use the previous versions of the browser.
Maybe not related directly to selenium use,
But in case of getting stuck in "under remote control" after having launched firefox with a kind of:
firefox -marionette -foreground -no-remote -profile /path/to/existing/profile
It's because this way it toggles marionette:true in about:config,
Thanks to Firefox Stuck in Remote Control Mode for pointing to this marionette config entry