Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
切换到新窗口无效selenium、python_Python_Selenium_Selenium Webdriver - Fatal编程技术网

切换到新窗口无效selenium、python

切换到新窗口无效selenium、python,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,单击每个链接时,新窗口将打开,需要使用开关获取打开的每个窗口的url。\u到。\u窗口不工作 有人能帮我解决这个问题吗 提前谢谢 import unittest from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebD

单击每个链接时,新窗口将打开,需要使用开关获取打开的每个窗口的url。\u到。\u窗口不工作

有人能帮我解决这个问题吗

提前谢谢

import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time


class slTest(unittest.TestCase):

def test_santi(self):
      self.browser=webdriver.Ie("C:\Users\chethan\Documents\IEDriverServer.exe")
    self.browser.implicitly_wait(5)
    self.browser.get("http://myqesite.com/banners.php")

    #vr=self.browser.execute_script("return initValues")
    curr=self.browser.current_window_handle
    print curr
    num=0
    res=self.browser.find_element_by_id("productcontainer")
    links=res.find_elements_by_tag_name("a")
    for link in links:
        link.click()
        time.sleep(2)
        open_windows = self.browser.window_handles
        self.browser.switch_to_window(open_windows[-1])
        print "current: ", self.browser.current_url


        print link.get_attribute("id")
        #print self.browser.current_url
        num=num+1

    print num
    #self.browser.quit()


if __name__ == "__main__":
unittest.main()