#from playwright.sync_api import sync_playwright, Browser #from marionette_driver.marionette import Marionette #import marionette #import pyatspi import lxml.etree from lxml.cssselect import CSSSelector from lxml.etree import _Element from typing import List if __name__ == "__main__": #with sync_playwright() as plwr: #while True: ##try: #thunderbird: Browser = plwr.firefox.connect("http://127.0.0.1:6000", timeout=60) #break ##except: ##pass #for ctx in thunderbird.contexts: #for p in ctx.pages: #print(p.url) #thunderbird = Marionette() #print(thunderbird.start_session()) #print(thunderbird.chrome_window_handles) #print(thunderbird.window_handles) #print(thunderbird.current_chrome_window_handle) #thunderbird.set_context(Marionette.CONTEXT_CONTENT) #print(thunderbird.current_window_handle) #thunderbird.switch_to_window(thunderbird.chrome_window_handles[0]) #thunderbird.switch_to_default_content() #thunderbird.switch_to_frame() #print(thunderbird.get_url()) #print(thunderbird.get_window_type()) #thunderbird.fullscreen() #print(thunderbird.close()) #registry = pyatspi.Registry.get_default() #registry #xml = "../../任务数据/Thunderbird/vertical-card-view.xml" xml = "../../任务数据/Thunderbird/vertical-table-view.xml" at: _Element = lxml.etree.parse(xml) #elements: List[_Element] = CSSSelector('application[name=Thunderbird] page-tab-list')(at) # page tab tags #elements: List[_Element] = CSSSelector('application[name=Thunderbird] panel>scroll-pane>internal-frame>panel[name$="anonym-x2024@outlook.com"]')(at) # email tag page #elements: List[_Element] = CSSSelector('application[name=Thunderbird] panel>scroll-pane>internal-frame>panel[name$="anonym-x2024@outlook.com"]>section:nth-child(3)')(at) # email tag page #elements: List[_Element] = CSSSelector('application[name=Thunderbird] panel>scroll-pane>internal-frame>panel[name$="anonym-x2024@outlook.com"]>section[attr|id=threadPane]>section[attr|id="threadTree"]>table[attr|class="tree-table"]>section[attr|class~="tree-table-header"]>table-row>column-header[name=Subject]>push-button', namespaces={"attr": "uri:deskat:attributes.at-spi.gnome.org"})(at) # table view, column header elements: List[_Element] = CSSSelector('application[name=Thunderbird] panel>scroll-pane>internal-frame>panel[name$="anonym-x2024@outlook.com"]>section[attr|id=threadPane]>section[attr|id="threadTree"]>table[attr|class="tree-table"]>tree>tree-item>section[name="Subject"]>section>section', namespaces={"attr": "uri:deskat:attributes.at-spi.gnome.org"})(at) # table view, column header print(len(elements)) for elm in elements: print(lxml.etree.tostring(elm, encoding="unicode", pretty_print=True))