pywinauto/others – getting opened tabs url from Edge
Question:
I have question about possibility to get url of all opened tabs in Edge browser.
I have started with pywinauto and I have possibility to get all tab names from Chrome or from Edge:
from pywinauto import Desktop
desktop = Desktop(backend="uia")
window = desktop.windows(title_re="edge", control_type="Window")[0] # change title_re to "chrome" to get values for chrome browser
wrapper_list = window.descendants(control_type="TabItem")
tab_names = [tab.window_text() for tab in wrapper_list]
And yes, I’m getting all opened Edge tabs.
I have also checked the code below:
import pywinauto
app = pywinauto.Application(backend='uia')
app.connect(title_re=".*Microsoft​ Edge.*", found_index=0)
dlg = app.top_window()
wrapper = dlg.child_window(title="App bar", control_type="ToolBar")
url = wrapper.descendants(control_type='Edit')[0]
print(url.get_value())
With no success – the "url = wrapper.descendants(control_type=’Edit’)[0]" returns error:
"ElementNotFound"
So… how to use it to get url of all the opened tabs? Or just one by using it’s title?
It’s not necessary to use pywinauto of course.
Have a nice day!
Answers:
there is more easier way to do that, and it do more, for example,get title of each tab:
from clicknium import clicknium as cc
if not cc.edge.extension.is_installed():
cc.edge.extension.install_or_update()
for browser in cc.edge.browsers:
for tab in browser.tabs:
print(tab.url)
I have question about possibility to get url of all opened tabs in Edge browser.
I have started with pywinauto and I have possibility to get all tab names from Chrome or from Edge:
from pywinauto import Desktop
desktop = Desktop(backend="uia")
window = desktop.windows(title_re="edge", control_type="Window")[0] # change title_re to "chrome" to get values for chrome browser
wrapper_list = window.descendants(control_type="TabItem")
tab_names = [tab.window_text() for tab in wrapper_list]
And yes, I’m getting all opened Edge tabs.
I have also checked the code below:
import pywinauto
app = pywinauto.Application(backend='uia')
app.connect(title_re=".*Microsoft​ Edge.*", found_index=0)
dlg = app.top_window()
wrapper = dlg.child_window(title="App bar", control_type="ToolBar")
url = wrapper.descendants(control_type='Edit')[0]
print(url.get_value())
With no success – the "url = wrapper.descendants(control_type=’Edit’)[0]" returns error:
"ElementNotFound"
So… how to use it to get url of all the opened tabs? Or just one by using it’s title?
It’s not necessary to use pywinauto of course.
Have a nice day!
there is more easier way to do that, and it do more, for example,get title of each tab:
from clicknium import clicknium as cc
if not cc.edge.extension.is_installed():
cc.edge.extension.install_or_update()
for browser in cc.edge.browsers:
for tab in browser.tabs:
print(tab.url)