跳转新标签页获取元素
from DrissionPage import Chromium browser = Chromium() tab = browser.latest_tab tab.get('https://www.163.com/') tab.ele('tag:a@@class=fontb').click() tab1 = browser.latest_tab tab1.ele('tag:a@@class=ntes-nav-select-title ntes-nav-select-title-register').click()
第二种写法
from DrissionPage import ChromiumPage dp = ChromiumPage() dp.get('https://www.163.com/') # dp.ele('tag:a@@class=fontb').click() tab = dp.ele('tag:a@@class=fontb').click.for_new_tab() # tab = dp.latest_tab tab.ele('tag:a@@class=ntes-nav-select-title ntes-nav-select-title-register').click()