BlogHitsRobot.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:AutoTestFramework 作者: huilansame 项目源码 文件源码
def clk(driver, url):
    """locate and click url"""
    locator = (By.XPATH, '//span[contains(text(), "{0}")]/../../../../a'.format(url))
    try:
        WebDriverWait(driver, 5, 0.5).until(EC.element_to_be_clickable(locator))
        try:
            moved_to_element = driver.find_element_by_xpath('//span[contains(text(), "{0}")]'.format(url))
            target_element = driver.find_element(*locator)
            ActionChains(driver).move_to_element(to_element=moved_to_element).click(target_element).perform()
            sleep(1)
            if 'm.baidu.com' in driver.current_url:
                target_element.click()
            return 1
        except:
            return 0
    except TimeoutException:
        return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号