【发布时间】:2017-03-20 09:08:32
【问题描述】:
我正在尝试提取 URL,将它们打开到新选项卡中,然后执行一些操作。我的代码是-
urls = self.driver.find_elements_by_xpath('//div[@id="maincontent"]/table/tbody/tr/td//a[@href]')
for url in urls:
try:
href = url.get_attribute("href")[28:]
print href
actions = ActionChains(self.driver)
url_1 = self.driver.find_element_by_xpath('//*[@href="'+href+'"]')
actions.key_down(Keys.CONTROL).click(url_1).key_up(Keys.CONTROL).perform()
except Exception, e:
print e
actions1 = ActionChains(self.driver)
actions1.key_down(Keys.CONTROL).key_down(Keys.TAB).key_up(Keys.TAB).key_up(Keys.CONTROL).perform()
print "hi"
show_report = self.driver.find_element_by_xpath('//*[@value="Show Report(s)"]')
show_report.click()
它在新选项卡中打开 URL,但不对它们执行操作。我该怎么办??
【问题讨论】: