Example #1
0
 def __init__(self, driver=None):
     if driver is None:
         options = Options()
         options.debugger_address('localhost:9222')
         self._driver = webdriver.Chrome(options=options)
     else:
         self._driver: WebDriver = driver
     if self._url != "":
         self._driver.get(self._url)
Example #2
0
 def __init__(self, base_obj=None):
     if base_obj is None:
         option = Options()
         option.debugger_address("localhost:9222")
         self.driver = webdriver.Chrome(options=option)
         self.driver.get(
             "https://work.weixin.qq.com/wework_admin/frame#index")
     else:
         self.driver = base_obj
     self.driver.implicitly_wait(5)
 def test_debug_login(self):
     option = Options()
     # Google\ Chrome --remote-debugging-port = 9222
     # 需要和启动命令的端口号一致
     option.debugger_address = "localhost:9222"
     self.driver = webdriver.Chrome(options=option)
     self.driver.get("https://work.weixin.qq.com/wework_admin/loginpage_wx")
Example #4
0
 def setup_method(self, method):
     option = Options()
     option.debugger_address = '127.0.0.1:9222'
     self.driver = webdriver.Chrome(options=option)
     # self.driver = webdriver.Chrome()
     # 隐式等待,动态的等待元素,最好在实例化driver之后立刻去设置
     self.driver.implicitly_wait(5)
    def setup_method(self):

        # 浏览器复用
        chrome_options = Options()
        chrome_options.debugger_address = "127.0.0.1:9222"
        self.driver = webdriver.Chrome("/usr/local/bin/chromedriver",
                                       options=chrome_options)
Example #6
0
 def setup(self):
     option = Options()
     option.debugger_address = 'localhost:9222'
     self.driver = webdriver.Chrome(
         r'C:\myTestTool\chromedriver\chromedriver.exe', options=option)
     self.driver.get(
         "https://work.weixin.qq.com/wework_admin/frame#contacts")
 def setup_method(self, method):
     option = Options()
     option.debugger_address = "localhost:9222"
     #        self.driver = webdriver.Chrome(options=option)
     self.driver = webdriver.Chrome()
     self.driver.maximize_window()
     self.driver.implicitly_wait(5)
Example #8
0
 def test_cookie(self):
     option = Options()
     option.debugger_address = '127.0.0.1:9222'
     self.driver = webdriver.Chrome(options=option)
     self.driver.get('https://work.weixin.qq.com/wework_admin/frame#inde')
     cookies = self.driver.get_cookies()
     print(cookies)
Example #9
0
    def __init__(self, driver: WebDriver = None):
        option = Options()
        option.debugger_address = "localhost:9222"
        db = shelve.open('mydb')
        self._driver = ""
        if driver is None:
            self._driver = webdriver.Chrome(options=option)
        else:
            self._driver = driver
        if self._base_url != "":
            self._driver.get(self._base_url)

        #self._driver.get("https://work.weixin.qq.com/wework_admin/frame")
        c1 = self._driver.get_cookies()
        db['cookie'] = c1
        cookies = db['cookie']
        for cookie in cookies:
            if 'expiry' in cookie.keys():
                cookie.pop('expiry')
            self._driver.add_cookie(cookie)
        if self._base_url != "":
            self._driver.get(self._base_url)
        #self._driver.get("https://work.weixin.qq.com/wework_admin/frame")

        self._driver.implicitly_wait(3)
    def test_reuse_session(self):
        option = Options()
        option.debugger_address = 'localhost:9222'
        self.driver = webdriver.Chrome(options=option)
        self.driver.get("https://ezrouting.freshchat.com/")

        self.driver.find_element_by_css_selector()
Example #11
0
 def setup(self):
     # 浏览器复用
     option = Options()
     option.debugger_address = '127.0.0.1:9222'
     self.driver = webdriver.Chrome(options=option)
     # self.driver = webdriver.Chrome()
     self.driver.implicitly_wait(5)
 def setup(self):
     options = Options()
     # options.binary_location = r"C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe"
     options.debugger_address = "127.0.0.1:9222"
     self.driver = webdriver.Chrome(options=options)
     self.driver.maximize_window()
     self.driver.implicitly_wait(10)
Example #13
0
 def setup(self):
     options = Options()
     options.debugger_address = "127.0.0.1:9999"
     # self.driver = webdriver.Chrome(options=options)
     self.driver = webdriver.Chrome()
     self.driver.maximize_window()
     self.driver.implicitly_wait(3)
Example #14
0
 def setup(self):
     option = Options()
     # chrome --remote-debugging-port=9222
     # 注意 9222 端口要与命令行启动的端口保持一致 --remote-debugging-port=9222
     option.debugger_address = "127.0.0.1:9222"
     self.driver = webdriver.Chrome(options=option)
     self.driver.implicitly_wait(5)
Example #15
0
 def setup_class(self):
     #浏览器复用:1.将Chrome的启动文件添加到环境变量,2.执行命令chrome --remote-debugging-port=9222
     #注意需要把其他谷歌浏览器关掉。
     # """
     options = Options()
     options.debugger_address = '127.0.0.1:9222'
     self.driver = webdriver.Chrome(chrome_options=options)
Example #16
0
 def setup_method(self):
     # 网页复用
     option = Options()
     option.debugger_address = "127.0.0.1:9222"
     self.driver = webdriver.Chrome(options=option)
     # 全局隐式等待
     self.driver.implicitly_wait(5)
Example #17
0
 def setup(self):
     option = Options()
     option.debugger_address = 'localhost:9222'
     self.driver = webdriver.Chrome(options=option)
     self.driver = webdriver.Chrome()
     self.driver.implicitly_wait(5)
     self.driver.maximize_window()
 def setup(self):
     option = Options()
     option.debugger_address = "localhost:9222"
     option.add_experimental_option("w3c", False)
     self.driver = webdriver.Chrome(options=option)
     self.driver.maximize_window()
     self.driver.implicitly_wait(3)
Example #19
0
 def setup(self):
     # 复用浏览器,debugger模式,复用浏览器的时候cmd不能关,关了就相当于进程结束了,
     # 复用浏览器的时候要提前打开所要打开的页面,
     option = Options()
     option.debugger_address = "127.0.0.1:9222"
     #如果需要复用浏览器,则需要在括号中加入:options=option,如果不复用就不用加
     self.driver = webdriver.Chrome()
Example #20
0
 def __init__(self,
              driver: WebDriver = None,
              platform="web",
              desired_caps=None):
     """
     实例化时如果传入 driver,直接使用 传入的 driver,如果没有则判断 platform ,并生成对应的driver
     默认生成 selenium webdriver
     暂时只实现了web 和 android 平台
     :param platform: 平台,web android ios
     :param driver:
     :param desired_caps: Android 平台的 desired_capabilities
     """
     self.project_path = Common().parse_path().get("project_path")
     if driver is None:
         if platform == "web":
             webdriver = selenium.webdriver
             options = Options()
             options.debugger_address = "127.0.0.1:9999"
             self._driver = webdriver.Chrome(
                 executable_path=ChromeDriver().get_driver(),
                 options=options)
             self._driver.implicitly_wait(3)
         elif platform == "android":
             webdriver = appium_webdriver
             self._driver = webdriver.Remote('http://localhost:4723/wd/hub',
                                             desired_caps)
             self._driver.implicitly_wait(10)
         elif platform == "ios":
             pass
     else:
         self._driver = driver
     if self._base_url != "":
         self._driver.get(self._base_url)
         self.log.info(f'访问地址:{self._base_url}')
Example #21
0
 def setup_class(self):
     option = Options()
     option.debugger_address = 'localhost:9222'
     self.driver = webdriver.Chrome(options=option)
     self.url = "https://work.weixin.qq.com/wework_admin/frame#index"
     self.driver.implicitly_wait(5)
     self.driver.maximize_window()
 def setup(self):
     option = Options()
     option.debugger_address = "localhost:9222"
     self.driver = webdriver.Chrome(options=option)
     # self.driver.get("https://www.bilibili.com/")
     self.driver.maximize_window()
     self.driver.implicitly_wait(5)
Example #23
0
 def test_fuyong(self):
     option = Options()
     # 使用Google\ Chrome - -remote - debugging - port = 9222
     option.debugger_address = "localhost:9222"
     driver = webdriver.Chrome(options=option)
     # 先手动登陆一次然后再次访问
     driver.get("https://work.weixin.qq.com/wework_admin/frame#contacts")
Example #24
0
 def setup(self):
     option = Options()
     option.debugger_address = "localhost:9222"
     self.driver = webdriver.Chrome(options=option)
     self.driver.get(
         "https://work.weixin.qq.com/wework_admin/frame#contacts")
     self.driver.implicitly_wait(3)
Example #25
0
    def setup_method(self):

        option = Options()
        option.debugger_address = "127.0.0.1:9222"
        self.driver = webdriver.Chrome(options=option)
        self.driver.get("https://work.weixin.qq.com/wework_admin/frame#index")
        self.vars = {}
Example #26
0
 def setup_method(self, method):
     chrome_options = Options()
     # 和浏览器打开的调试端口进行通信
     # 浏览器要使用 --remote-debugging-port=9222 开启调试
     chrome_options.debugger_address = "127.0.0.1:9222"
     self.driver = webdriver.Chrome(options=chrome_options)
     self.driver.implicitly_wait(5)
Example #27
0
    def get_driver(self):

        cur_path_list = os.getcwd().split("/")[:-1]
        cur_path = "/".join(
            cur_path_list) + "/dependencies/chromedriver/chromedriver"

        if not os.path.exists(cur_path):
            self.dl_driver_mac()

        cur_path_list = os.getcwd().split("/")[:-1]
        cur_path = "/".join(cur_path_list) + "/config/"
        cmd = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-' \
              'dir="{}" '.format(cur_path)
        subprocess.Popen(cmd, shell=True)

        chrome_options = Options()
        chrome_options.debugger_address = "127.0.0.1:9222"

        cur_path_list = os.getcwd().split("/")[:-1]
        cur_path = "/".join(
            cur_path_list) + "/dependencies/chromedriver/chromedriver"

        driver = webdriver.Chrome(cur_path, options=chrome_options)
        cmd = """ osascript -e 'tell application "System Events" to keystroke "h" using {command down}' """
        os.system(cmd)
        return driver
Example #28
0
 def setup_method(self, method):
     # options = Options()
     # options.debugger_address = "127.0.0.1:9222"
     # self.driver = webdriver.Chrome(options=options)
     options = Options()
     options.debugger_address = "127.0.0.1:9222"
     self.driver = webdriver.Chrome()  # options=options
Example #29
0
    def setup_method(self, method):
        options = Options()
        options.debugger_address = "127.0.0.1:9222"
        # self.driver = webdriver.Chrome(options=options)
        self.driver = webdriver.Chrome()

        self.driver.implicitly_wait(3)
Example #30
0
 def setup_method(self, method):
     options = Options()
     options.debugger_address = "127.0.0.1:9222"
     # 复用模式
     self.driver = webdriver.Chrome('/Users/apple/Documents/web/chromedriver', options=options)
     # self.driver = webdriver.Chrome('/Users/apple/Documents/web/chromedriver')
     self.vars = {}
Example #31
0
    def launch_webdriver(self):
        options = Options()
        options.binary_location = ''
        options.debugger_address = '{}:{}'.format(
            DEFAULT_WEBVIEW_INSPECTOR_IP,
            DEFAULT_WEBVIEW_INSPECTOR_PORT)

        self.driver = webdriver.Chrome(
            executable_path=CHROMEDRIVER_EXEC_PATH,
            chrome_options=options)

        self.assertThat(self.driver, NotEquals(None))