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 webshot(args):
"""
Mass web screenshot function
"""
targets = [url.rstrip() for url in args.f]
timeout = args.t
# set up headless browser
try:
browser = webdriver.PhantomJS(
service_log_path=os.path.devnull,
service_args=["--ignore-ssl-errors=true"])
browser.set_page_load_timeout(timeout)
browser.set_window_size(1920, 1080)
except Exception as err:
print("// error: {0}".format(err))
browser.quit()
sys.exit(1)
# create output directory
outdir = "webshots-" + time.strftime("%Y%m%d-%H%M%S", time.localtime())
try:
os.mkdir(outdir, mode=0o755)
except Exception as err:
print("// error: {0}".format(err))
browser.quit()
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--window-size=1920x1080")
driver = webdriver.Chrome(chrome_options=options)
elif driver_name == "firefox":
from selenium.webdriver.firefox.options import Options
options = Options()
options.add_argument("--headless")
options.add_argument("--window-size=1920x1080")
driver = webdriver.Firefox(firefox_options=options)
elif driver_name == "safari":
driver = webdriver.Safari()
driver.implicitly_wait(10)
yield driver
driver.quit()
chromeOps.add_argument('--disable-setuid-sandbox')
elif sys.platform.startswith("linux"):
if 'Ubuntu' in platform.linux_distribution():
chromedriver_path = "/usr/lib/chromium-browser/chromedriver"
elif 'debian' in platform.linux_distribution():
#Debian is lowercase when platform.linux_distribution() is used.
#This is not a mistake.
chromedriver_path = "/usr/lib/chromium/chromedriver"
else:
# Let's hope it's in the user's path.
chromedriver_path = "chromedriver"
try:
# First argument is optional, if not specified will search path.
driver = webdriver.Chrome(chromedriver_path, chrome_options=chromeOps)
except WebDriverException as e:
error = e.__str__()
if "executable needs to be in PATH" in e.__str__():
print "ChromeDriver isn't installed. Check test/chrome/README.md " \
"for instructions on how to install ChromeDriver"
sys.exit(2)
else:
raise e
print ''
driver.get('http://libssh.org/robots.txt')
test_failed = False
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
def click_button_and_save(name_to_xpaths, dir_name, save=True):
for name, xpath in name_to_xpaths.items():
button = self.driver.find_element(By.XPATH, xpath)
button.click()
if save:
WebDriverWait(self.driver, 20).until(
EC.presence_of_element_located((By.ID, "cytoscape"))
)
path = os.path.join(
os.path.dirname(__file__),
'screenshots',
dir_name,
name + '.png'
)
self.driver.save_screenshot(path)
def waitEditRuleModal(browser):
WebDriverWait(browser, 10).until(Condition.visibility_of_element_located((By.ID, 'edit-automation-rule-modal')))
modals.waitForOpened(browser.find_element_by_id('edit-automation-rule-modal'))
return EditRuleModal(browser.find_element_by_id('edit-automation-rule-modal'))
def setUp(self):
if (config.local):
self.wd = webdriver.Firefox()
else:
desired_capabilities = webdriver.DesiredCapabilities.FIREFOX
desired_capabilities['version'] = '24'
desired_capabilities['platform'] = 'Linux'
desired_capabilities['name'] = 'test_access'
self.wd = webdriver.Remote(
desired_capabilities=desired_capabilities,
command_executor="http://esodvn:325caef9-81dd-47a5-8b74-433057ce888f@ondemand.saucelabs.com:80/wd/hub"
)
self.wd.implicitly_wait(60)
def wait_for_element_by_css_selector(self, selector, timeout=TIMEOUT):
return WebDriverWait(self.driver, timeout).until(
EC.presence_of_element_located((By.CSS_SELECTOR, selector)),
'Could not find element with selector "{}"'.format(selector)
)
def test_har_is_updating():
try:
mob = mobidriver.Firefox(BROWSER_MOB_PATH, headless=True)
test_url = 'http://jkorpela.fi/forms/testing.html'
mob.get(test_url)
WebDriverWait(mob, 2).until(EC.title_is('Testing HTML forms'))
first_har = mob.har
mob.find_elements_by_tag_name('input')[2].click()
WebDriverWait(mob, 2).until(EC.title_is('Echoing submitted form data'))
new_har = mob.har
assert first_har != new_har
finally:
mob.quit()