52 qr_buttons = options.driver.find_element(by=By.ID, value="qr-buttons")
53 if qr_buttons.is_displayed():
54 qr_buttons.find_element(by=By.LINK_TEXT, value="X").click()
55 options.driver.find_element(by=By.CSS_SELECTOR, value=("input#check%s"%postID)).click()56 if password != "":
57 delPasswordInput = options.driver.find_element(
58 by=By.CSS_SELECTOR,
72 value="input[name=move_btn]").click()
73 # wait for response to move_btn
74 WebDriverWait(self.driver, 10).until(
75 EC.title_contains("Move thread #%s" % threadID)) 76
77 self.driver.find_element(
78 by=By.CSS_SELECTOR,
65 threadID = threadRE.findall(cur_url)[0][1]
66 self.driver.find_element(
67 by=By.CSS_SELECTOR,
68 value=("input#check%s"%threadID)).click() 69 cur_url = self.driver.current_url
70 self.driver.find_element(
71 by=By.CSS_SELECTOR,
69
70 argParser.add_argument("--browser", choices=testable_browsers, required=True)
71 argParser.add_argument("--site", default=testingSite,
72 help=("Sets the site to be used for testing, defaults to %s" % testingSite))73 argParser.add_argument("--board", default=testingBoard,
74 help="Sets the board to be used for testing")
75 argParser.add_argument("--headless", action="store_true",
29 if upload != "":
30 options.upload_path = upload
31
32 print("Using browser %s (headless: %s) on site %s" % (browser, options.headless, options.site))33 if single_test == "":
34 suite = unittest.suite.TestSuite()
35 SeleniumTestCase.add(suite, options, TestPosting)
f-strings are the fastest way to format strings as compared to the following methods:
%
format()
str.join
+
operator to concatinate stringTemplate.substitute
Some less preferred ways to format strings are the following:
from string import Template
menu = ('eggs', 'spam', 42.4)
old_order = "%s and %s: %.2f ¤" % menu # [consider-using-f-string]
beginner_order = menu[0] + " and " + menu[1] + ": " + str(menu[2]) + " ¤"
joined_order = " and ".join(menu[:2])
format_order = "{} and {}: {:0.2f} ¤".format(menu[0], menu[1], menu[2])
named_format_order = "{eggs} and {spam}: {price:0.2f} ¤".format(eggs=menu[0], spam=menu[1], price=menu[2])
template_order = Template('$eggs and $spam: $price ¤').substitute(eggs=menu[0], spam=menu[1], price=menu[2])
Consider using f-strings as shown below:
menu = ('eggs', 'spam', 42.4)
f_string_order = f"{menu[0]} and {menu[1]}: {menu[2]:0.2f} ¤"