Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
selenium Ctrl + F input
#1
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.
Recommended Tutorials:
Reply
#2
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 ...
Reply
#3
AH OK, so you cant do this with selenium alone then?
Recommended Tutorials:
Reply
#4
(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')
Reply
#5
I was assuming selenium had some mystic method of communicating to the browser itself.

But ill use PyAutoGUI, thats fine
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Code example for entering input in a textbox with requests/selenium object peterjv26 1 1,677 Sep-26-2020, 04:34 PM
Last Post: Larz60+
  Error in Selenium: CRITICAL:root:Selenium module is not installed...Exiting program. AcszE 1 3,587 Nov-03-2017, 08:41 PM
Last Post: metulburr
  Can't extract hidden input using Selenium!!! Shaggy89 1 2,793 Jul-12-2017, 12:24 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020