1

I'm trying to access the developer tools of the browser that I'm using (Firefox) using Selenium. I know that you can press F12 to access it, so I'm trying to "press" F12 using Selenium but I'm having some trouble.

browser = webdriver.Firefox()
type(browser)
browser.get('http://google.com')
browser.send_keys(u'\ue03c')

But when I do this, I get the error:

AttributeError: 'WebDriver' object has no attribute 'send_keys'

Is there a way to "press" keys without having to focus on an element?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Michael
  • 11
  • 1
  • 2
  • 2
    Why are you trying to access the dev tools with Selenium? This seems like it might be a http://xyproblem.info – jonrsharpe Mar 28 '17 at 08:07
  • Hi jon, I'm a beginner to python, and my end-goal is to access the dev tools using python. It does seem like I am approaching the problem incorrectly, do you know if there is a better method instead of manually "pressing" F12 using selenium? – Michael Mar 28 '17 at 08:12
  • 1
    @Michael, what do you want to do **after** dev tools opened? – Andersson Mar 28 '17 at 08:14
  • That doesn't seem like an actual end goal. What do you intend to *do*? What research have you done, e.g. I found http://stackoverflow.com/q/20401264/3001761 and http://stackoverflow.com/q/36311191/3001761 pretty quickly. – jonrsharpe Mar 28 '17 at 08:15
  • Hi andersson and jonrsharpe, apologies for not making it clear. After accessing the dev tools, I want to switch over to the Network tab and pull the data relating how much data is being transferred. Essentially just creating a small python tool to just monitor the bandwidth of a browser. – Michael Mar 28 '17 at 08:25
  • 1
    You won't be able to get data from Network tab with `selenium` as it is not part of a `DOM`. You can try to check this http://stackoverflow.com/questions/8958614/measure-network-data-with-python or provide with more details of what data you want to extract – Andersson Mar 28 '17 at 08:55

0 Answers0