当前位置: 首页>>代码示例>>Python>>正文


Python Marionette.switch_to_window方法代码示例

本文整理汇总了Python中marionette_driver.marionette.Marionette.switch_to_window方法的典型用法代码示例。如果您正苦于以下问题:Python Marionette.switch_to_window方法的具体用法?Python Marionette.switch_to_window怎么用?Python Marionette.switch_to_window使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marionette_driver.marionette.Marionette的用法示例。


在下文中一共展示了Marionette.switch_to_window方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: print

# 需要导入模块: from marionette_driver.marionette import Marionette [as 别名]
# 或者: from marionette_driver.marionette.Marionette import switch_to_window [as 别名]
addTarget = "var anchors = document.querySelectorAll('table td:nth-child(2) .meta a');for (var i=0; i<anchors.length; i++){anchors[i].setAttribute('target', '_blank');}"
result = client.execute_script(addTarget)
# Open all the links
openPages = client.find_elements(By.CSS_SELECTOR, 'table td:nth-child(2) .meta a')
print('Find ' + str(len(openPages)) + ' wrong strings for ' + args.search + ' with -> ' + args.remove)
i = 0
j = 0
for openPage in openPages:
    original_window = client.current_window_handle
    openPage.click()
    # Wait page load, glotpress is very slow
    time.sleep(1.5)
    all_tab = client.window_handles
    if all_tab[-1] != original_window:
        # Switch to the tab opened
        client.switch_to_window(all_tab[-1])
        Wait(client).until(logged_in)
        i += 1
        print(str(i) + ' - Switch to ' + client.find_element(By.CSS_SELECTOR, '.breadcrumb li:nth-child(3)').text)
        try:
            client.find_element(By.CSS_SELECTOR, 'dd button.reject').click()
            # Reject the translation
            time.sleep(1)
            Wait(client).until(gp_success)
            # If a replacing translation is set, submit it
            if args.replace:
                try:
                    client.find_element(By.CSS_SELECTOR, '.action.edit').click();
                    time.sleep(1)
                    client.find_element(By.CSS_SELECTOR, '.textareas').find_element(By.CSS_SELECTOR, '.foreign-text').clear()
                    client.find_element(By.CSS_SELECTOR, '.textareas').find_element(By.CSS_SELECTOR, '.foreign-text').send_keys(args.replace)
开发者ID:Mte90,项目名称:BulkRejectGP,代码行数:33,代码来源:bulkrejectgp.py


注:本文中的marionette_driver.marionette.Marionette.switch_to_window方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。