最后两个current_url获取到的页面链接不对,是什么哪里不对呢
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver=webdriver.Firefox()
url='https://www.baidu.com/'
driver.get(url)
time.sleep(4)
print(driver.current_url)#打印当前页面URL,正确
print(driver.title)
driver.implicitly_wait(5)
driver.find_element(By.ID,'kw').send_keys("先导入By模块")
driver.find_element(By.ID,'su').click()
time.sleep(4)
print(driver.current_url)#打印当前页面URL 正确
print(driver.title)
# driver.implicitly_wait(5)
driver.find_element(By.LINK_TEXT,"登录").click()
time.sleep(4)
print(driver.current_url)#打印当前页面URL 正确
print(driver.title)
driver.back()
# 10是最长等待时间,0.5是每0.5秒去查询对应的元素,util后面跟的是等待具体条件,EC跟的是判断条件判断元素是否在DOM上
WebDriverWait(driver, 10, 0.5,"超时").until(EC.presence_of_element_located((By.LINK_TEXT, "hao123")),message="")
driver.find_element(By.LINK_TEXT, "hao123").click()
time.sleep(4)
print(driver.current_url)#打印当前页面URL 错误:输出https://www.baidu.com/而不是hao123的链接
print(driver.title)
driver.forward()
time.sleep(4)
print(driver.current_url)#打印当前页面URL 错误:输出的是查询链接
print(driver.title)
driver.close()#关闭当前页面 错误:关闭了查询链接
time.sleep(4)
driver.quit()