Capture network traffic for firefox in selenium - selenium

I found this on stackoverflow for chrome, works fine
Capture network traffic using selenium webdriver java 4.0v
But how can I achieve this with firefox?
I can get all the logs with this code:
System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "/tmp/FFLogs.txt")
FirefoxOptions options = new FirefoxOptions()
options.setLogLevel(FirefoxDriverLogLevel.TRACE)
I get many log entries, but I do not figure out the ajax requests. How can I do this with firefox?

Related

I disabled loading images in chrome while using webdriver with selenium now cant enable it

I disabled loading images in chrome while using webdriver with selenium now cant enable it.
I was using python to webscrape on instagram so thought it would be a good idea to disable images.
The commands i used:
options = webdriver.ChromeOptions()
options.add_argument("--disable-gpu=true")
options.add_argument("--blink-settings=imagesEnabled=false")
And now I cannot change it from chrome settings.
Screenshot of chrome settings page.
Please Help.
Edit: This happens only in my default Chrome Profile. Other Profiles work fine even though the profile I use for selenium is a different one.
After a long day on google finally found the solution.
options.add_experimental_option("prefs", {'profile.managed_default_content_settings.images': 1})

Selenium capture IE and Edge console log

I'm able to use:
let browserLog = await browser.manage().logs().get('browser');
console.log(util.inspect(browserLog))
in chrome but, does not work for IE and Edge browsers.
Any suggestions?
You cannot. The only browser and driver that currently provides the console log is Chrome w/ Chromedriver. It may be added to the W3C Webdriver spec at a later date, follow this issue https://github.com/w3c/webdriver/issues/406

How to get redirected urls on a headless server

Please suggest a method of getting final urls after redirection in an automated way. It has to run on my headless Ubuntu server.
Selenium will only start a browser in headless mode on this server, else error:
opts = FirefoxOptions()
opts.add_argument("--headless")
But this way the .current_url method on a webdriver instance does not get the redirect, whereas on my PC with normal display mode I am getting the redirect correctly.
Solving this with tools other than Selenium would be great, too.

webGL dependent application in opening in chrome

I have a situation here that we have a webGL dependent application to automate. i have automated the whole application on my laptop, and this application is running fine on chrome on my laptop. but the issue is when i run this application from a seperate machine which is a selenium GRID node. It gives me a message that the application required Webgl and and it ask me to enable the webGL. i have tried different methods like selenium option and ignoring the chrome black list as well.
when i open the browser manually and open the application it runs find and i checked on url chrome://gpu. it shows that the gpu is enaled.
but when i invoke the selenium and run the test cases,. the browser initiates with WebGl as disabled
i found the solution to this. here is the code you can use to enable WebGL for chrome.
DesiredCapabilities capability = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
**options.addArguments("--ignore-gpu-blacklist");**
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capability.setCapability("chrome.binary", "C:\\Temp\\chromedriver.exe");
capability.setVersion("9999");
capability.setCapability(ChromeOptions.CAPABILITY, options);
return new RemoteWebDriver(HUB_URL,capability);

Selenium interpret javascript on mac?

I'm trying to make a web crawler that click on ads (yes, i know), it's very sophisticated, but, I realise that Google Ads aren't showed when javascript is disabled. Today, i use Mechanize, and it doesn't "accept" javasript.
I heard selenium use another system to crawl the net.
The only thing I want to do is access my page, and click on the ad (generated by javascript).
Can Selenium do it ?
Selenium is a browser automation tool. You can basically automate everything you can do in your browser. Start with going through the Getting Started section of the documentation.
Example:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.python.org")
print driver.title
driver.close()
Besides automating common browsers, like Chrome, Firefox, Safari or Internet Explorer, you can also use PhantomJS headless browser.