Python Forum

Full Version: selenium Ctrl + F input
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to get search text in Firefox via its built in "find in page" search Ctrl + F

You can easily achieve bringing up the searchbox via actionchains
ActionChains(self.browser).send_keys(Keys.CONTROL, "f").perform()
However i cant figure out how to send keys to the input box. There is no HTML for it. You cannot inspect the element because its not part of the page. So how can I input text into this inputbox?

Can you just arbitrarily just type keys instead of sending it to an element? Because once you bring up the search box it has focus.
After open need to go over to something that can simulate keyboard actions.
I see someone has used Robot(Java) for this SO.
Python has several libraries that may work for this, take a look at eg PyAutoGUI, Keyboard, PyUserInput ...
AH OK, so you cant do this with selenium alone then?
(Jul-14-2019, 11:10 AM)metulburr Wrote: [ -> ]AH OK, so you cant do this with selenium alone then?
No,can call it as you do,but when box is open it's not html so then there is nothing to select and send to.

How it work with html.
<form>
  User name:<br>
  <input type="text" name="username"><br>
  User password:<br>
  <input type="password" name="psw">
</form>
Then from Selenium can find that element bye name,Xpath,CSS...,and send character to that element.
elem = driver.find_element_by_name('username')
elem.send_keys('Kent')
I was assuming selenium had some mystic method of communicating to the browser itself.

But ill use PyAutoGUI, thats fine