Title

selenium前进后退,异常处理

### selenium前进后退,异常处理

```python
brower = webdriver.Chrome()
brower.get('https://www.pearvideo.com/')
brower.implicitly_wait(10)
brower.maximize_window()
print(brower.window_handles)
brower.execute_script('window.open()')

brower.switch_to.window(brower.window_handles[1])  # 切换到选项卡
brower.get('http://www.taobao.com')
time.sleep(3)
input_name = brower.find_element(By.CSS_SELECTOR, '#q')
ss_name = brower.find_element(By.CSS_SELECTOR, '#J_TSearchForm > div.search-button > button')
input_name.send_keys('布娃娃')
ss_name.click()
brower.back()  # 后退
time.sleep(3)
brower.forward()  # 前进
# # 异常处理
# '''
# try:
# '''
# time.sleep(2)
# brower.close()
posted @ 2023-07-11 18:10  哈哈哈哼  阅读(39)  评论(0编辑  收藏  举报