Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Set the name, description and type of the action
self.selenium.find_element_by_id('id_name').send_keys(action_name)
desc = self.selenium.find_element_by_id('id_description_text')
desc.send_keys(
'Provide feedback about the project using the results '
+ 'from the rubric')
# Select the action type
select = Select(self.selenium.find_element_by_id('id_action_type'))
select.select_by_value(Action.RUBRIC_TEXT)
self.modal_ss('rubric_create.png')
self.cancel_modal()
# Open the action
self.open_action_edit(action_name)
WebDriverWait(self.selenium, 10).until(
EC.element_to_be_clickable(
(By.XPATH, '//div[contains(@class, "note-editable")]')
)
)
self.body_ss('rubric_edit_text.png')
# Go to the rubric tab
self.select_rubric_tab()
self.body_ss('rubric_edit_table_tab.png')
# Preview
self.open_preview()
self.modal_ss('rubric_preview.png')
self.cancel_modal()
# End of session
self.logout()
# wait for Graph to be ready
WebDriverWait(dash_dcc.driver, 10).until(
EC.visibility_of_element_located(
(By.CSS_SELECTOR, "#graph-2-tabs .main-svg")
)
)
dash_dcc.percy_snapshot(
"Tabs with Graph - clicked tab 2 (graph should not resize) ({})".format(
"eager" if is_eager else "lazy"
)
)
WebDriverWait(dash_dcc.driver, 10).until(
EC.element_to_be_clickable((By.ID, "tab-1"))
)
tab_one.click()
# wait for Graph to be loaded after clicking
WebDriverWait(dash_dcc.driver, 10).until(
EC.visibility_of_element_located(
(By.CSS_SELECTOR, "#graph-1-tabs .main-svg")
)
)
dash_dcc.percy_snapshot(
"Tabs with Graph - clicked tab 1 (graph should not resize)"
)
takes string ref or object Ref
:param ref:
:param filter: "all", "Rashi", etc
:return:
"""
if isinstance(ref, basestring):
ref = Ref(ref)
assert isinstance(ref, Ref)
url = self.base_url + "/" + ref.url()
if filter is not None:
url += "&with={}".format(filter)
if lang is not None:
url += "&lang={}".format(lang)
self.driver.get(url.replace("&", "?", 1))
if filter == "all":
WebDriverWait(self.driver, TEMPER).until(element_to_be_clickable((By.CSS_SELECTOR, ".categoryFilter")))
elif filter is not None:
# Filters load slower than the main page
WebDriverWait(self.driver, TEMPER).until(element_to_be_clickable((By.CSS_SELECTOR, ".filterSet > .textRange")))
else:
WebDriverWait(self.driver, TEMPER).until(
element_to_be_clickable((By.CSS_SELECTOR, ".textColumn .textRange .segment")))
WebDriverWait(self.driver, TEMPER).until(element_to_be_clickable((By.CSS_SELECTOR, ".linkCountDot")))
self.set_modal_cookie()
return self
@when(ur'the user clicks (?Pthe first context menu option|a choice '
ur'for wrapping text in new elements|'
ur'a choice for creating an element (?:before|after) the selected '
ur'element|'
ur'a choice for creating a new (?P.*)|'
ur'the choice named "(?P.*)")')
def step_impl(context, choice, new=None, name=None):
util = context.util
driver = context.driver
# The following branches also normalize ``choice`` to shorter values
if choice == "the first context menu option":
choice = "first"
link = util.wait(EC.element_to_be_clickable(
(By.CSS_SELECTOR, ".wed-context-menu li>a")))
elif choice == "a choice for wrapping text in new elements":
choice = "wrap"
link = util.wait(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT,
"Wrap in ")))
elif (choice ==
"a choice for creating an element before the selected element"):
choice = "before"
link = [x for x in util.find_descendants_by_text_re(
".wed-context-menu", "^Create new .+? before")
if x.tag_name == "a"][0]
util.wait(lambda *_: link.is_displayed())
elif (choice ==
"a choice for creating an element after the selected element"):
choice = "after"
link = [x for x in util.find_descendants_by_text_re(
def waitForElement(self, locator, locatorType="id",
timeout=10, pollFrequency=0.5):
element = None
try:
byType = self.getByType(locatorType)
self.log.info("Waiting for maximum :: " + str(timeout) +
" :: seconds for element to be clickable")
wait = WebDriverWait(self.driver, 10, poll_frequency=1,
ignored_exceptions=[NoSuchElementException,
ElementNotVisibleException,
ElementNotSelectableException])
element = wait.until(EC.element_to_be_clickable((byType,
"stopFilter_stops-0")))
self.log.info("Element appeared on the web page")
except:
self.log.info("Element not appeared on the web page")
print_stack()
return element
def parse_jobs(jobs_urls):
"""Parse all jobs data"""
global jobs
# Open jobs URLs one by one to get page html
jobs_html = []
for url in jobs_urls:
browser.execute_script("window.open('{}', 'new_window')".format(url))
browser.switch_to.window(browser.window_handles[1])
# Waite till all page data loaded
try:
WebDriverWait(browser, 20).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, 'a.secondary-text'))
)
except TimeoutException:
browser.close()
browser.switch_to.window(browser.window_handles[0])
continue
'''
WebDriverWait(browser, 20).until(
EC.presence_of_all_elements_located((By.CSS_SELECTOR, '.description-section p'))
)
'''
jobs_html.append(browser.page_source)
# Close the current windows and switch to the main window
browser.close()
browser.switch_to.window(browser.window_handles[0])
def _find_next_page_element(self):
"""Finds the element that locates the next page for any search engine.
Returns:
The element that needs to be clicked to get to the next page or a boolean value to
indicate an error condition.
"""
if self.search_type == 'normal':
selector = self.next_page_selectors[self.search_engine_name]
try:
# wait until the next page link is clickable
WebDriverWait(self.webdriver, 5).until(EC.element_to_be_clickable((By.CSS_SELECTOR, selector)))
except (WebDriverException, TimeoutException):
self._save_debug_screenshot()
# raise Exception('{}: Cannot locate next page element: {}'.format(self.name, str(e)))
try:
return self.webdriver.find_element_by_css_selector(selector)
except Exception:
logger.error('failed find_element_by_css_selector, sleep 30 sec')
time.sleep(30)
pass
elif self.search_type == 'image':
self.page_down()
if self.search_engine_name == 'google':
return self.webdriver.find_element_by_css_selector('input._kvc')
else:
return True
if go_back_one_day:
browser.find_element_by_xpath(INPUT_XPATH % day_prior_id).click()
# need a delay here, otherwise the next find element statement will find
# the *old* datePicker text box.
time.sleep(5)
# Read out the day the data applies to
the_day = browser.find_element_by_xpath(INPUT_XPATH % date_id).get_attribute("value")
# Hover over the cog icon in the lower right of the graph
element = browser.find_element_by_xpath(IMG_XPATH % cog_id)
hov = ActionChains(browser).move_to_element(element)
hov.perform()
# Need to wait for the "Details" icon to show before clicking it.
detail_object = WebDriverWait(browser, 7).until(EC.element_to_be_clickable((By.XPATH, INPUT_XPATH % detail_id)))
detail_object.click()
# Switch to the Details window that popped up and get the HTML
# from it.
browser.switch_to_window(browser.window_handles[1])
WebDriverWait(browser, 30).until(EC.presence_of_element_located((By.XPATH, "//table[contains(@id, 'Table1')]")))
result_html = browser.page_source
browser.close()
# Have Pandas read the HTML and extract the data from the table within
# it. The first (and only) table contains the data we want.
df = pd.read_html(result_html)[0]
df.columns = ['Time', 'Power']
# Convert Power values to numeric. Handle rows that don't have power
# values according to the fill_NA parameter.
def wait_till_clickable(selector):
if cur_route:
selector = cur_route + " " + selector
return get_wait().until(EC.element_to_be_clickable((By.CSS_SELECTOR, selector)))
def choose(seletor):
try:
# 控件可点击时才选定
choice = wait.until(EC.element_to_be_clickable((By.XPATH, seletor)))
return choice
except TimeoutException as e:
print("Time out!")
return None
except Exception:
print("Not found!")
return None