本文整理匯總了Python中marionette_driver.marionette.Marionette.find_elements方法的典型用法代碼示例。如果您正苦於以下問題:Python Marionette.find_elements方法的具體用法?Python Marionette.find_elements怎麽用?Python Marionette.find_elements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類marionette_driver.marionette.Marionette
的用法示例。
在下文中一共展示了Marionette.find_elements方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: space
# 需要導入模塊: from marionette_driver.marionette import Marionette [as 別名]
# 或者: from marionette_driver.marionette.Marionette import find_elements [as 別名]
except:
print "Already logged"
# Move to the term
term = args.search
# encode the term and change the space ('%20') in a '+'
term = urllib.quote_plus(term, safe='')
client.navigate("https://translate.wordpress.org/consistency?search=" + term + "&set=" + args.lang + "%2Fdefault")
# Remove the strings different from our
removeOtherStrings = "var right = document.querySelectorAll('table td:nth-child(2) .string');for (var i=0; i<right.length; i++){if(right[i].innerHTML!=='" + cgi.escape(args.remove.replace("'","\\'")) + "') {td = right[i].parentNode;tr = td.parentNode;tr.outerHTML=''}}"
result = client.execute_script(removeOtherStrings)
# Force to open the link in another tab with a little hack in js
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)