from selenium import webdriver
import time
drive = webdriver.Firefox()
url='https://www.jd.com/'
drive.get(url)
aa=drive.find_element_by_xpath(".//*[@id='ttbar-login']/a[1]")
aa.click()
bb=drive.find_element_by_xpath(".//*[@id='kbCoagent']/ul/li[1]/a/span")
bb.click()
el=drive.find_element_by_id("ptlogin_iframe")
drive.switch_to.frame(el)
cc=drive.find_element_by_xpath(".//*[@id='img_out_597137047']")
cc.click()
time.sleep(5)
dd=drive.find_element_by_xpath(".//*[@id='key']")
dd.send_keys("游戏本")
ee=drive.find_element_by_xpath(".//*[@id='search']/div/div[2]/button")
ee.click()
# time.sleep(5)
ff=drive.find_element_by_xpath(".//*[@id='J_goodsList']/ul/li[1]/div/div[7]/a[3]")
ff.click()
list=drive.window_handles
for i in list:
print(i)
drive.switch_to_window(list[1])
drive.find_element_by_class_name("btn-tobback").click()