Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_edit_collage_search(self):
"""剪辑-画中画-GIF搜索."""
sc.logger.info('剪辑-画中画-GIF搜索')
fun_name = 'test_edit_collage_search'
start_x = self.width // 2
start_bottom = self.height // 3
sc.logger.info('点击创作中心主按钮')
c_btn = 'com.quvideo.xiaoying:id/img_creation'
WebDriverWait(sc.driver, 10, 1).until(
lambda el: el.find_element_by_id(c_btn)).click()
# sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_creation').click()
sc.logger.info('点击“更多草稿”')
sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click()
sc.logger.info('点击草稿封面')
draft_img = 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb'
sc.driver.find_element_by_id(draft_img).click()
sc.logger.info('点击“剪辑”')
WebDriverWait(sc.driver, 10, 1).until(
lambda c_btn: c_btn.find_element_by_android_uiautomator(
'text("剪辑")')).click()
t_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/title')
for el_item in t_list:
def click_toc_text(self, text_name):
# Assume that text link is already present on screen (or soon will be)
selector = '.refLink[data-ref^="{}"]'.format(text_name)
WebDriverWait(self.driver, TEMPER).until(
presence_of_element_located((By.CSS_SELECTOR, selector))
)
WebDriverWait(self.driver, TEMPER).until(
element_to_be_clickable((By.CSS_SELECTOR, selector))
)
p1 = self.driver.find_element_by_css_selector(selector)
p1.click()
WebDriverWait(self.driver, TEMPER).until(
element_to_be_clickable((By.CSS_SELECTOR, '.segment'))
)
return self
row_link_elem = driver.find_element_by_id(row_link_id)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, row_link_id)))
row_link_elem.click()
except NoSuchElementException as error:
print("Error: {0}".format(error))
exit()
except StaleElementReferenceException:
print("Dom updated, retrying click")
continue
break
#Grab info
for attempt in range(0, 3):
try:
WebDriverWait(driver, 10).until(EC.visibility_of(driver.find_element_by_id("mpeDetail_foregroundElement")))
booking_number = driver.find_element_by_id("lblBKNo").get_attribute("innerText")
full_name = driver.find_element_by_id("InmateData1_lblFullName").get_attribute("innerText")
arrest_date = driver.find_element_by_id("InmateData1_lblArrDt").get_attribute("innerText")
race = driver.find_element_by_id("InmateData1_lblRace").get_attribute("innerText")
sex = driver.find_element_by_id("InmateData1_lblSex").get_attribute("innerText")
age = driver.find_element_by_id("InmateData1_lblAge").get_attribute("innerText")
charge_rows = driver.find_elements_by_css_selector("table#InmateData1_dlChgs > tbody > tr")
charge_rows_count = len(charge_rows) - 1 #Subtract column header
for charge_num in range(0, charge_rows_count):
charge_selector = "InmateData1_dlChgs_lblChg_{0}".format(charge_num)
charge_bond_selector = "InmateData1_dlChgs_lblBondAmt_{0}".format(charge_num)
charge_status_selector = "InmateData1_dlChgs_lblDisp_{0}".format(charge_num)
charge = driver.find_element_by_id(charge_selector).get_attribute("innerText")
def item_members(self, name):
"""Item add members."""
element_locator = By.XPATH, ("//ul[contains(@class,"
" 'available_update_members')]"
"/ul[contains(., '{}')]//a".format(name))
return WebDriverWait(self.webelement, config.UI_TIMEOUT).until(
ec.presence_of_element_located(element_locator))
def the_owner_is_name_in_the_title_column(step, name, title):
selector = ("//h2[contains(.,'{}')]/../../../"
"descendant::a[contains(@class,'switcher-top')]"
"//span[@class='title'][contains(text(),'{}')]").format(title,
name)
wait = ui.WebDriverWait(world.browser, 5)
wait.until(visibility_of_element_located((By.XPATH, selector)))
def search(self,dork,period):
self.banner()
print '[+] Starting g00gle search engine.. \n'
# Config settings for driver of selenium
driver = webdriver.Firefox()
driver.wait = WebDriverWait(driver, 20)
# Config of xpaths that will be used to make the search
searchTools = "hdtb-tls"
option_lastYear = "//li[contains(@id,'qdr_y')]"
option_lastMonth = "//li[contains(@id,'qdr_m')]"
option_lastWeek = "//li[contains(@id,'qdr_w')]"
option_last24h = "//li[contains(@id,'qdr_d')]"
botonAnyTime = "//div[contains(@class,'hdtb-mn-hd') and .//text()='Em qualquer data']"
navigationBar = ".//*[@id='nav']"
# Making the search
# On this line: driver.get("https://www.google.com.br")
# You can change the google domain, but the --period parameter will only works, if the google is .br
# Ex: driver.get("https://www.google.ru")
def the_panel_is_called_title(step, panel, title):
selector = "td.panel-container.open.%s" % panel.lower()
wait = ui.WebDriverWait(world.browser, 5)
panel = wait.until(
presence_of_element_located((By.CSS_SELECTOR, selector)))
elt = panel.find_element_by_name("title")
val = elt.get_attribute("value")
assert val == title, "Nope: %s" % val
def __init__(self, driver):
self.driver = driver or webdriver.Firefox()
self.wait = WebDriverWait(self.driver, 5)
def wait_for_element_present(self,locator,timeout=30):
"""Waits until element specified with 'locator' present on current page.
Fails if 'timeout' expires before the element appears.
Default timeout is set to 10s, it can be used to override the default value.
"""
try:
WebDriverWait(Util.driver, float(timeout)).until(EC.presence_of_element_located(locator))
except TimeoutException:
self._warn("Wait for element '%s' timeout in '%s'"%(locator,float(timeout)))