I need to retrieve the search result of the Chrome search box (ctrl + F). My python script requires the number of matches to my keywords. For example, the matching result for 'fibril structure' is '1/12' here, and I need to copy this '1/12'.ctrl+f search result for 'fibril structure'
Here is my attempt so far:
from pywinauto.application import Application
from pywinauto.keyboard import SendKeys
app = Application()
app.start(r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")
app=Application().connect(title='New Tab - Google Chrome')
window=app.Chrome_WidgetWin_1
window.TypeKeys('^F')
window.TypeKeys('hello world')
window.print_control_identifiers()
I have tried Pywinauto but I wasn't able to locate this dialog. Besides, the webpage where I am running the 'ctrl+F' operation is actually a web PDF (https://sci-hub.do/10.1038/s41594-020-0496-3), and because of that I couldn't locate my element using the xpath method in Selenium.
Can someone provide me some hints on how I can get this done?
You have to add this code after your code:
desktop = pywinauto.Desktop(backend='uia', allow_magic_lookup=False)
window = desktop.windows(title='New Tab - Google Chrome', control_type='Pane')[0]
result = window.descendants(control_type='StatusBar')[0]
print(result.texts())