TA的每日心情 | 奋斗 2016-6-24 10:43 |
---|
签到天数: 2 天 连续签到: 2 天 [LV.1]测试小兵
|
3#
楼主 |
发表于 2016-6-24 10:43:08
|
只看该作者
model=driver.find_element_by_xpath("/html/body/div[1]/div[1]/div/ul/li[2]")#点击样板中心
ActionChains(driver).move_to_element(model).click().perform()
print("切换到样板中心")
time.sleep(3)
driver.switch_to_frame("templateCenterIframe")
print(driver.current_window_handle)
driver.find_element_by_xpath("//*[@id='tplArea']/div[1]/div[3]").click()
driver.current_window_handle
print("复制样板")
这里复制后,会在当前窗口打开新的页面
driver.switch_to_default_content()
temp =driver.window_handles #获取所有窗口句柄
print(driver.switch_to_window(temp[-1]))
print("编辑传单")
新窗口下面的就无法执行了
text=driver.find_element_by_xpath("/html/body/div[3]/div[1]/div[2]/div/div[1]/span")
ActionChains(driver).move_to_element(text).click().perform()
print("添加文本")
报错:Traceback (most recent call last):
File "C:\Python35-32\wcd_test.py", line 81, in <module>
text=driver.find_element_by_xpath("/html/body/div[3]/div[1]/div[2]/div/div[1]/span")
File "C:\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 290, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 744, in find_element
{'using': by, 'value': value})['value']
File "C:\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 233, in execute
self.error_handler.check_response(response)
File "C:\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element
(Session info: chrome=49.0.2623.110)
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)
|
|