def get_data(driver):
    # Initalizing empty dict values
    data = dict({
        "categoryName": "",
        "categoryValue": "",
        "Phone": "",
        "Email": "",
        "Website": "",
        "Address": "",
        "BusinessProfile": "",
    })
    try:
        removed_ad(driver)
        data_page_main = W(driver, 10).until(
            EC.presence_of_element_located(
                (By.CLASS_NAME, "container.hf-bdp.p-3")))
        print("A1")

        print("B")
        # Adding Category
        category_field = data_page_main.find_elements_by_class_name(
            "lead.hfhl")
        print("C")

        try:
            data["categoryName"] = category_field[0].text
            data["categoryValue"] = category_field[1].text
        except:
            pass
        try:
            Business_profile = driver.find_elements_by_id("description")[0]
            description = Business_profile.find_elements_by_tag_name("small")
            data["BusinessProfile"] = description[0].text
        except:
            pass
        # Adding Phone, Website and Address
        first_table_data_page = W(data_page_main, 10).until(
            EC.presence_of_element_located((By.CLASS_NAME, "row.small")))

        labels = first_table_data_page.find_elements_by_class_name(
            "col-3.col-md-2.py-1")
        values = first_table_data_page.find_elements_by_class_name(
            "col-9.col-md-10.py-1")
        print("F")

        keys = []
        for label in labels:
            keys.append(label.text)

        index = 0
        for value in values:
            data[keys[index]] = value.text
            index = index + 1
    except Exception as e:
        print(e)

    return data
def answered(d, question_number):
    wait_variable = W(d, wait_time_out)
    answer_element = wait_variable.until(
        E.presence_of_element_located(
            (By.NAME, "answer" + str(question_number))))
    if "Correct." in answer_element.get_attribute("value"):
        return True
    else:
        return False
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as W
from selenium.webdriver.support import expected_conditions as E
from selenium.webdriver import ActionChains as A
from selenium.webdriver.common.keys import Keys as K
import pyautogui as P
import time

exec_path = r"C:\Users\NASA7\Downloads\chromedriver_win32 (4)\chromedriver.exe"
URL = r"https://inderpsingh.blogspot.com/2014/08/demowebapp_24.html"
#URL2=r"https://crossbrowsertesting.github.io/drag-and-drop"
#headling_css_locator=".post-body>div:nth-child(1)>div:nth-child(1)>form:nth-child(1)>h3:nth-child(1)"
distance_id_locator = "distance"
wait_time_out = 15
driver = webdriver.Chrome(executable_path=exec_path)
wait_variable = W(driver, wait_time_out)
driver.get(URL)
distance_element = wait_variable.until(
    E.presence_of_element_located((By.ID, distance_id_locator)))
distance_element.send_keys("")
P.write("123456.78")
P.press("backspace", 3)
P.hotkey("ctrl", "a")
P.hotkey("ctrl", "c")
P.sleep(1)
P.press("tab")
P.hotkey("ctrl", "v")
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as W
from selenium.webdriver.support import expected_conditions as E
import time

exec_path = r"C:\Users\NASA7\Downloads\chromedriver_win32 (4)\chromedriver.exe"
URL = r"https://inderpsingh.blogspot.com/2013/04/SeleniumWebDriverQuiz4.html"
wait_time_out = 5
#answer1_radio_id_locator="1"
answer_name_locator = "answer"
score_id_locator = "score"

driver = webdriver.Chrome(executable_path=exec_path)
wait = W(driver, wait_time_out)
driver.get(URL)
for q in range(1, 7):
    for a in range(1, 5):
        radio_element = wait.until(
            E.presence_of_element_located((By.ID, str(q) + str(a))))
        radio_element.click()
        time.sleep(1)
        answer_element = wait.until(
            E.visibility_of_element_located(
                (By.NAME, answer_name_locator + str(q))))
        if "Correct." in answer_element.get_attribute("value"):
            break

score_element = wait.until(
    E.visibility_of_element_located((By.ID, score_id_locator)))
if "6/6" in score_element.text:
Пример #5
0
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as W
from selenium.webdriver.support import expected_conditions as E
import time

exec_path = r"C:\Users\NASA7\Downloads\chromedriver_win32 (4)\chromedriver.exe"
URL = r"https://www.wikipedia.org"
#english_link_locator="js-link-box-en"
language_locators = ["js-link-box-en", "js-link-box-ru", "js-link-box-de"]
search_locator = "searchInput"
search_text = "Software"
wait_time = 5

driver = webdriver.Chrome(executable_path=exec_path)
driver.get(URL)
wait = W(driver, wait_time)
driver.implicitly_wait(5)
driver.maximize_window()
for i in range(len(language_locators)):
    #language_link=driver.find_element(By.ID, language_locators[i])
    language_link = wait.until(
        E.presence_of_element_located((By.ID, language_locators[i])))
    language_link.click()
    #input_box_element=driver.find_element(By.ID, search_locator)
    input_box_element = wait.until(
        E.presence_of_element_located((By.ID, search_locator)))
    input_box_element.send_keys(search_text)
    input_box_element.submit()
    time.sleep(4)
    driver.back()
    driver.back()
def second_page_pagination_handling(sheet, row_counter, category_name):
    print("9")
    second_page_index = 1
    while True:
        print("10")
        # if second_page_index == 3:
        #     print("A1")
        #     break
        if second_page_index != 1:
            try:
                print("11")
                removed_ad(driver)
                next_page = driver.find_element_by_xpath(
                    "//a[contains(text(),'Next')]")
                removed_ad(driver)
                next_page.click()
                removed_ad(driver)
                is_next_page_clicked = True
            except:
                print("12")
                is_next_page_clicked = False

            try:
                print("13")
                if is_next_page_clicked == False:
                    driver.get("https://www.hotfrog.com/search/us/" +
                               category_name + "/" + second_page_index)
                    removed_ad(driver)
                    try:
                        print("14")
                        driver.find_element_by_xpath(
                            "//a[contains(text(),'Next')]")
                    except:
                        print("15")
                        print(category_name + "reached to " + category_name +
                              " :: Breaking for other categories")
                        break
            except:
                print("16")
                second_page_index = second_page_index + 1
                continue
        is_second_page_list_found = False
        try:
            print("17")
            time.sleep(10)
            second_page_list = driver.find_elements_by_xpath(
                "//h3[contains(@class,'h6 mb-0')]")  # taking time
            total_result = len(second_page_list)
            is_second_page_list_found = True
        except:
            print("18")
            driver.get("https://www.hotfrog.com/search/us/" + category_name +
                       "/" + second_page_index)
            removed_ad(driver)
            second_page_list = driver.find_elements_by_xpath(
                "//h3[contains(@class,'h6 mb-0')]")
            total_result = len(second_page_list)
            is_second_page_list_found = True
        if is_second_page_list_found == False:
            print("19")
            second_page_index = second_page_index + 1
            continue

        print("total_result", total_result)
        for i in range(0, total_result):
            print("20")
            removed_ad(driver)
            time.sleep(20)
            try:
                print("21")
                # time.sleep(5)
                second_page_main = W(driver, 10).until(
                    EC.presence_of_element_located(
                        (By.CLASS_NAME, "serpspage")))
                removed_ad(driver)
                second_page_list_temp = second_page_main.find_elements_by_xpath(
                    "//h3[contains(@class,'h6 mb-0')]")
                removed_ad(driver)
                print("22")
                category = second_page_list_temp[i]
                clickable_cat = W(category, 10).until(
                    EC.presence_of_element_located((By.TAG_NAME, "a")))
                print("23")
                clickable_cat.click()
                print("23")
                # Need to wait till reload the page
                # time.sleep(20)
                removed_ad(driver)
            except Exception as e:
                print("23A continue", e)
                continue
            try:
                # import pdb;pdb.set_trace()
                print("24")
                data = get_data(driver)
                print(data)
                if data["categoryName"] != "":
                    append_data(data, sheet, row_counter)
                    row_counter = row_counter + 1
            except:
                print("24A")
                pass

            if driver.current_url != "https://www.hotfrog.com/search/us/" + category_name:
                try:
                    print("25")
                    driver.back()
                    removed_ad(driver)
                    print("Completed " + str(i))
                except:
                    print("26")
                    print("Skiped " + str(i))
        second_page_index = second_page_index + 1
        print("27")
Пример #7
0
 def __init__(self, drv):
     self.drv = drv
     self.wait_variable = W(self.drv, self.WAIT_TIME_OUT)
Пример #8
0
 def __init__(self, drv):
     self.drv = drv
     self.wait_variable = W(self.drv, self.wait_time_out)
     drv.get(C.base_url)
     drv.maximize_window()
Пример #9
0
    browser.execute_script("window.open('https://docs.google.com/document/d/1XoCLRKiO7lJNLF8a4z2PmCvbjYtJF4RNlkMpw5pFZe0/edit','new window')")
    handles = browser.window_handles
    time.sleep(2)
    browser.switch_to.window(handles[1])
    action = ActionChains(browser)
    action.key_down(Keys.CONTROL).send_keys("a").perform()
    action.key_down(Keys.CONTROL).send_keys("c").perform()
    time.sleep(2)

    browser.switch_to.window(handles[0])
    action = ActionChains(browser)
    job_desc = browser.find_element_by_xpath('//*[@id="mceu_12"]')
    action.click_and_hold(job_desc).perform()
    action.key_down(Keys.CONTROL).send_keys("v").perform()
    
    
    remove_tick=browser.find_element_by_xpath('//*[@id="create_signal_wrapper"]/div/div[2]/div[2]/div[23]/div/div/globalcheckbox/div/div[1]/div')
    remove_tick.click()

    Addprefer=browser.find_element_by_xpath('//*[@id="create_signal_wrapper"]/div/div[2]/div[2]/div[25]/div/div[1]/div/span[2]')
    action.double_click(Addprefer).perform()
    
    time.sleep(5)

    submit=browser.find_element_by_xpath('//*[@id="matches_workflow_wrapper"]/div[2]/div/div/div[8]/div/div[2]/div/div[2]/div[1]/span[2]')
    submit.click()
    
    W(browser, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="setup_job_incoming_automation_container"]/div/div/div[3]/div/div/div[1]'))).click()

    browser.quit()
Пример #10
0
    browser.find_element_by_xpath('//*[@id="postJobButton"]').click()

    #     handles = browser.window_handles
    #     print(handles)

    time.sleep(5)

    #browser.save_screenshot("sample.png")

    #indeed_job_title_xpath = '/html/body/div[2]/div[3]/div[1]/div[3]/div[3]/div[1]/div[3]/div[3]/div/div/div/div/div/div[2]/div/div/div[4]/div/div/div/div/div[1]/div/div/div/div[2]/input'
    #indeed_job_title_click = browser.find_element_by_xpath(indeed_job_title_xpath)
    #e = browser.find_element_by_css_selector('input.JobTitle')
    #e.send_keys(data[i]['fields']['Position Name']);
    #indeed_job_title_click.send_keys(data[i]['fields']['Position Name']);

    element = W(browser, 10).until(
        EC.presence_of_element_located((By.XPATH, '//*[@id="JobTitle"]')))
    element.send_keys(data[i]['fields']['Position Name'])

    #browser.find_element_by_xpath('//*[@id="plugin_container_CoreFunnel_JobTitleContainer"]/div/div/div/div/div/div/div/div[2]').send_keys(data[i]['fields']['Position Name']);

    #time.sleep(2)

    indeed_loc_xpath = '//*[@id="cityOrPostalCode"]'
    indeed_loc_xpath_click = browser.find_element_by_xpath(indeed_loc_xpath)
    indeed_loc_xpath_click.send_keys("Mumbai")

    indeed_hires_xpath = '//*[@id="IntHiresNeeded_Stepper-1"]'
    indeed_hires_click = browser.find_element_by_xpath(indeed_hires_xpath)
    indeed_hires_click.send_keys(data[i]['fields']['Positions Open'])

    indeed_next_xpath = '//*[@id="sheet-next-button"]/span/a'
Пример #11
0
 def __init__(self, drv):
     self.drv = drv
     self.wait_variable = W(self.drv, self.wait_time_out)
Пример #12
0
        '//*[@id="AppendedJobDescription-editor-content"]')
    action.click_and_hold(indeed_job_desc).perform()
    action.key_down(Keys.CONTROL).send_keys("v").perform()

    indeed_nxt = '//*[@id="sheet-next-button"]/span/a'
    browser.find_element_by_xpath(indeed_nxt).click()

    time.sleep(10)

    #indeed_off_xpath = '//*[@id="QualificationsVisibility"]/div[1]/div[2]/div/label/div[2]/div/div[2]'
    #browser.find_element_by_xpath(indeed_off_xpath).click()
    #//*[@id="QualificationsVisibility"]/div[1]/div[2]/label/div[1]

    W(browser, 20).until(
        EC.element_to_be_clickable(
            (By.XPATH,
             '//*[@id="QualificationsVisibility"]/div[1]/div[2]/label/div[1]'
             ))).click()

    #indeed_off_2_xpath = '//*[@id="SkillsAssessmentVisibility"]/div[1]/div[2]/div/label/div[2]'
    #browser.find_element_by_xpath(indeed_off_2_xpath).click()

    W(browser, 20).until(
        EC.element_to_be_clickable(
            (By.XPATH,
             '//*[@id="SkillsAssessmentVisibility"]/div[1]/div[2]/label/div[1]'
             ))).click()

    time.sleep(2)

    indeed_nxt_xpath = '//*[@id="sheet-next-button"]/span/a'
Пример #13
0
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait as W
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

path = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(path)
driver.get('https://www.wikipedia.org/')

# find the english lang and click on it
en_box = driver.find_element_by_id('js-link-box-en')
en_box.click()

# we will use implicit wait until the even is finished
wait = W(driver, 5)
search_dh = wait.until(EC.presence_of_element_located((By.NAME, "search")))

# send software to search textbox and get this value and then press enter
search_dh.send_keys("software")
print(search_dh.get_attribute('value'))
search_dh.submit()

driver.quit()