def servicenow_incident_status_check(driver):

	try:
		wait(driver, 25).until(EC.presence_of_element_located((By.ID, "sysparm_search"))) #!!!! searching the incident
		time.sleep(2)

		indentations("Searching for the Incident...")
		element3=driver.find_element_by_id("sysparm_search")
		element3.clear()
		element3.send_keys(Incident + Keys.ENTER)
		
		wait(driver, 15).until(EC.frame_to_be_available_and_switch_to_it("gsft_main"))
		wait(driver, 15).until(EC.presence_of_element_located((By.ID, "incident.state")))
		time.sleep(5) #test as below implicit wait is not working #@@this is working but find a workaround

		#driver.implicitly_wait(10)  #newline added #19031938 as there was incident.state no such elementfound error
		#time.sleep(5) # for testing to be deleted as element_type is always showing text
		indentations("Checking the status of the ticket")
		
		""" need to work on it
		if driver.find_element_by_id("sys_readonly.incident.state"): #newline addedd becoz if the incident is closed it's still shows as select type
			print("this condition is runing can code baseon this")
		"""


		element_type=driver.find_element_by_id("incident.state").get_attribute("type")
		print("\n"+"\n"+"Printing the type of incident.state element",element_type) #test to be deleted #19031710
		time.sleep(4) #test to be deleted #19031710
		selectval=""   #copied from normal.py# 1531344 new line as when no server is found timeout exception is raised so putting if else for that and when it is not found selectval which is returmed on next line will not wriitten nodata error but blank
		
		if( element_type != "text" and element_type != "input"):
			select = Select(driver.find_element_by_id('incident.state')) #it's input but kept variable name as select to compare
			selectval=select.first_selected_option.text
			print("\n"+"\n"+"in incident check status in if that is select,val of selectval is...",selectval)
		else:
			select=driver.find_element_by_id('incident.state')
			selectval=select.get_attribute('value')
			print("\n"+"\n"+"in incident check status in else that is text input,val of selectval is...",selectval)

		driver.switch_to.default_content()  #19031449 #coz can get frame issue

		time.sleep(5) #for testing del it

		if(selectval.strip().lower()== 'resolved' or selectval.strip().lower()== 'closed' or selectval.strip().lower()== '7'):   #!!!already resolved
			indentations("Ticket is already resolved.So, Moving on to Next Incident")
			autostatus="already in resolved state"
			resolve_status=1 #1 means already resolved
			print("\n"+"\n"+"in incident check status in if that is resolve_status,val of selectval is...",resolve_status)

		else:
			resolve_status=0
			autostatus="The ticket is not in resolved state"
			print("\n"+"\n"+"in incident check status in else that is resolve_status,val of selectval is...",resolve_status)
		
	except NoSuchElementException:
		autostatus="The connection was slow hence unable to find element"
		resolve_status=0
		selectval=""

	return driver,selectval,autostatus,resolve_status
Ejemplo n.º 2
0
def Download_SLD(roadnum):
    
    driver = webdriver.Chrome('chromedriver.exe')
    driver.get("http://www2.dot.state.fl.us/Straight-linesOnlineGIS")
    
    #elem = Select(driver.find_element_by_id("cboDistrict"))
    #elem.select_by_visible_text("D1")
    #
    #elem = Select(driver.find_element_by_id("cboCounty"))
    #elem.select_by_visible_text("LEE")
    
    elem = driver.find_element_by_id("cboRoadway")
    all_options = elem.find_elements_by_tag_name("option")
    for option in all_options:
        if roadnum in option.get_attribute("text"): 
            roadnum_string = option.get_attribute("text")
            break
    
    elem = Select(driver.find_element_by_id("cboRoadway"))
    elem.select_by_visible_text(roadnum_string)
    
    driver.find_element_by_id("btnLaunch").click()
    time.sleep(5)
    
    driver.switch_to_window(driver.window_handles[1])
    elem = driver.find_element_by_id("plugin")
    url = elem.get_attribute("src")
    print (url)
    urllib.urlretrieve(url, "test2.pdf")
    driver.close()
Ejemplo n.º 3
0
    def test_change_hop_form(self):
        model.Hop(name="Simcoe",
                  origin='US',
                  alpha_acid=13,
                  description='Sample Description')
        model.commit()
        self.b.refresh()

        for step in ('Mash', 'Boil', 'Ferment'):
            self.b.find_element_by_link_text(step).click()

            label = 'Add Dry Hops...' if step == 'Ferment' else 'Add Hops...'
            self.b.find_element_by_link_text(label).click()
            self.b.find_element_by_link_text("Simcoe (US)").click()

            s = Select(
                self.b.find_element_by_css_selector(
                    '.%s .addition .form select' % step.lower()))
            s.select_by_visible_text('Pellet')
            self.blur()
            time.sleep(2)

            self.b.refresh()

            s = self.b.find_element_by_css_selector(
                '.%s .addition .form select' % step.lower())
            assert s.get_attribute('value') == 'PELLET'
Ejemplo n.º 4
0
    def test_change_hop_form(self):
        model.Hop(
            name="Simcoe",
            origin='US',
            alpha_acid=13,
            description='Sample Description'
        )
        model.commit()
        self.b.refresh()

        for step in ('Mash', 'Boil', 'Ferment'):
            self.b.find_element_by_link_text(step).click()

            label = 'Add Dry Hops...' if step == 'Ferment' else 'Add Hops...'
            self.b.find_element_by_link_text(label).click()
            self.b.find_element_by_link_text("Simcoe (US)").click()

            s = Select(self.b.find_element_by_css_selector(
                '.%s .addition .form select' % step.lower()
            ))
            s.select_by_visible_text('Pellet')
            self.blur()
            time.sleep(2)

            self.b.refresh()

            s = self.b.find_element_by_css_selector(
                '.%s .addition .form select' % step.lower()
            )
            assert s.get_attribute('value') == 'PELLET'
Ejemplo n.º 5
0
                    EC.element_to_be_clickable((By.LINK_TEXT, 'Prices')))
                elem.click()

                wait = WebDriverWait(driver, 10)
                elem = Select(
                    wait.until(
                        EC.element_to_be_clickable(
                            (By.ID, 'id_tax_rules_group'))))
                elem.select_by_value('53')

                wait = WebDriverWait(driver, 10)
                elem = wait.until(
                    EC.element_to_be_clickable((By.ID, 'priceTI')))
                elem.clear()
                elem.send_keys(str(karta.price))
                if (elem.get_attribute('value') == ""):
                    sleep(smallsleep)
                    elem.send_keys(str(karta.price))
                elem.send_keys(Keys.RETURN)
                sleep(normalsleep)
                elem = driver.find_element_by_name("submitAddproduct")
                driver.execute_script(
                    "var x = document.getElementsByName(\"submitAddproduct\"); x[0].click();"
                )
                wait = WebDriverWait(driver, 10)
                elem = wait.until(
                    EC.element_to_be_clickable(
                        (By.NAME, 'productFilter_b!name')))
            except TimeoutException:
                try:
                    wait = WebDriverWait(driver, 10)
def webscrape(username, password):

    parent = Tk()
    parent.withdraw()

    # This variable prevents the created therapy grid from being loaded into Python twice
    # in the event of an error
    therapy_grid_status = "Not loaded"

    # This initializes the selenium gecko webdriver and prevents it from creating logs
    browser = webdriver.Firefox(log_path='')
    browser.get('https://columbine.achievematrix.com/')

    # Subgoal 1: Getting the information to login to MatrixCare

    emailElem = browser.find_element_by_id('j_username')
    emailElem.send_keys(username)

    passwordElem = browser.find_element_by_id('j_password')
    passwordElem.send_keys(password)

    linkElem = browser.find_element_by_class_name('loginbtn')

    linkElem.click()  # Attempts to login to MatrixCare

    # Subgoal 2: Navigating to report on MatrixCare.

    try:
        facility_elem = browser.find_element_by_name('facility_name')
    except:
        facility_elem = False

    if facility_elem:
        pass
    else:

        messagebox.showinfo('Error', 'The MatrixCare login information ' \
                            'entered was incorrect. In a moment you will be' \
                            ' prompted to re-try.')

        browser.quit()
        parent.destroy()

        win32clipboard.OpenClipboard()
        therapy_grid_path_prep = win32clipboard.GetClipboardData()
        therapy_grid_path_prep = therapy_grid_path_prep.split(',')
        therapy_grid_path = therapy_grid_path_prep[0]
        win32clipboard.CloseClipboard()

        xl = win32com.client.Dispatch('Excel.Application')
        xl.DisplayAlerts = False
        xl.Workbooks.Open(therapy_grid_path)
        xl.Run('Import_Worksheet')
        therapy_grid_status = "Loaded"

        sys.exit()

    facility_elem.send_keys('Centre Avenue')

    search_elem = browser.find_element_by_name('search')
    search_elem.click()  # Executes the search

    facility_elem = browser.find_element_by_link_text(
        'CENTRE AVENUE HEALTH & REHAB - Ft. Collins, CO')
    facility_elem.click()

    reports_elem = browser.find_element_by_xpath('/html/body/nav[1]')

    action = ActionChains(browser)
    action.move_to_element(reports_elem)
    action.move_by_offset(-175, 0)
    action.click().perform()

    time.sleep(.5)

    reports_elem = browser.find_element_by_xpath(
        '//a[@href="/Zion?zionpagealias=REPORTMENUFACILITY"]')
    reports_elem.click()

    reports_elem = browser.find_element_by_id('ReportRadio202')
    reports_elem.click()

    reports_elem = browser.find_element_by_name('Submit')
    reports_elem.click()

    reports_elem = Select(browser.find_element_by_name('REPORTOUTPUTTYPE'))
    reports_elem.select_by_value('6')

    reports_elem = browser.find_element_by_name('StartDateOpenPeriod')
    reports_elem_value = reports_elem.get_attribute("value")

    reports_elem_value = datetime.strptime(reports_elem_value, '%m/%d/%Y')

    reports_elem_value = reports_elem_value - relativedelta(months=1)

    reports_elem_value = reports_elem_value.strftime('%m/%d/%Y')

    reports_elem.clear()

    reports_elem.send_keys(reports_elem_value)

    reports_elem = browser.find_element_by_name('EndDateOpenPeriod')
    reports_elem_value = reports_elem.get_attribute("value")

    reports_elem_value = datetime.strptime(reports_elem_value, '%m/%d/%Y')

    reports_elem_value = reports_elem_value

    reports_elem_value = reports_elem_value.strftime('%m/%d/%Y')

    reports_elem.clear()

    reports_elem.send_keys(reports_elem_value)

    reports_elem = browser.find_element_by_id('ResidentStatusMulti')
    for option in reports_elem.find_elements_by_tag_name('option'):
        if option.text == "Admission":
            option.click()

    ActionChains(browser).key_down(Keys.CONTROL)

    for option in reports_elem.find_elements_by_tag_name('option'):
        if option.text == "Return":
            option.click()

    ActionChains(browser).key_up(Keys.CONTROL)

    reports_elem = browser.find_element_by_name('Submit')
    reports_elem.click()

    time.sleep(13)

    #pyautogui.press('down')

    # Subgoal 3: Downloading report and importing into therapy record system
    # Data is pulled from the cliboard, which was sent by the Excel
    # VBA in order to find the therapy record file

    pyautogui.press('enter')

    time.sleep(5)

    browser.quit()

    if therapy_grid_status == "Not loaded":

        win32clipboard.OpenClipboard()
        therapy_grid_path_prep = win32clipboard.GetClipboardData()
        therapy_grid_path_prep = therapy_grid_path_prep.split(',')
        therapy_grid_path = therapy_grid_path_prep[0]
        win32clipboard.CloseClipboard()

        xl = win32com.client.Dispatch('Excel.Application')
        xl.DisplayAlerts = False
        xl.Workbooks.Open(therapy_grid_path)
        xl.Run('Import_Worksheet')

        sys.exit()

    else:
        xl.Run('Import_Worksheet')
        sys.exit()
Ejemplo n.º 7
0
    driver.find_element_by_css_selector(
        'body > table > tbody > tr:nth-child(5) > td.main_content > table > tbody > tr > td > table > tbody > tr:nth-child(6) > td:nth-child(2) > select'
    ))
element.select_by_value('У$')

element = driver.find_element_by_css_selector(
    'body > table > tbody > tr:nth-child(5) > td.main_content > table > tbody > tr > td > table > tbody > tr:nth-child(12) > td > input[type="submit"]:nth-child(2)'
)
element.click()

time.sleep(3)

element = driver.find_element_by_css_selector(
    'body > table > tbody > tr:nth-child(5) > td.main_content > table:nth-child(5) > tbody > tr:nth-child(4) > td:nth-child(2) > font > table > tbody > tr > input[type="hidden"]:nth-child(103)'
)
count = int(element.get_attribute('value'))

#start on 8
author_selector = 'body > table > tbody > tr:nth-child(5) > td.main_content > table:nth-child(5) > tbody > tr:nth-child({}) > td:nth-child(2) > a'
theme_selector = 'body > table > tbody > tr:nth-child(5) > td.main_content > table:nth-child(5) > tbody > tr:nth-child({}) > td:nth-child(2) > b:nth-child(5)'

if ENV == 'PRODUCTION':
    connection = MySQLdb.connect(
        host="localhost",  # your host, usually localhost
        user="******",  # your username
        passwd="uTBzTrkuLnDl",  # your password
        db="topicthesisdb",
        charset='utf8')
else:
    connection = sqlite3.connect(
        r'C:\Users\Mr_DarkWolf\Desktop\graduate-work-table\topicthesisdb')
Ejemplo n.º 8
0
        element = Select(element)
        element.select_by_value(domain)

        element = driver.find_element_by_name("date1")
        element.send_keys(date_begin)

        temp = datetime.strptime(date_begin, '%d/%m/%Y') + timedelta(88)
        date_end = temp.strftime("%d/%m/%Y")

        element = driver.find_element_by_name("date2")
        element.send_keys(date_end)

        # Catch captcha
        element = driver.find_element_by_xpath(
            "//td[@class='cb']/form[1]/table[1]/tbody[1]/tr[6]/td[2]/img")
        src = element.get_attribute('src')
        urllib.request.urlretrieve(src, "screenshot.png")

        # Solve captcha
        image_link = "screenshot.png"
        user_answer = ImageCaptcha.ImageCaptcha(
            rucaptcha_key=RUCAPTCHA_KEY).captcha_handler(
                captcha_file=image_link)

        if user_answer['errorId'] == 0:
            # решение капчи
            print(user_answer['captchaSolve'])
            print(user_answer['taskId'])
        elif user_answer['errorId'] == 1:
            # Тело ошибки, если есть
            print(user_answer['errorBody'])