def test_02_add_user(self): driver = self.driver # # driver.get("https://online.actitime.com/ssarangmath/login.do") # # lgn = LoginPage(driver) # lgn.enter_username("*****@*****.**") # lgn.enter_pwd("Shar@8971") # lgn.click_login() # driver.implicitly_wait(10) # time.sleep(3) # # # Verify successful login # pageTitle = self.driver.title # self.assertEqual("actiTIME - Enter Time-Track", pageTitle, "Login not success") driver.find_element_by_xpath( "//*[@id='topnav']/tbody/tr/td[5]/a").click() driver.implicitly_wait(20) driver.find_element_by_xpath( "//*[@id='pageBody']/tbody/tr[1]/td[3]/div/div[3]").click() driver.find_element_by_id("createUserPanel_firstNameField").clear() driver.find_element_by_id("createUserPanel_firstNameField").send_keys( "Sharath") driver.find_element_by_id("createUserPanel_lastNameField").clear() driver.find_element_by_id("createUserPanel_lastNameField").send_keys( "Sarangmath") driver.find_element_by_id("createUserPanel_emailField").clear() driver.find_element_by_id("createUserPanel_emailField").send_keys( "createUserPanel_emailField")
def browser(config_browser, config_wait_time, request): # Initialize WebDriver if config_browser == 'chrome': options = Options() options.add_argument('log-level=3') options.add_argument("--window-size=1920,1080") options.add_argument("--disable-extensions") options.add_argument("--proxy-server='direct://'") options.add_argument("--proxy-bypass-list=*") options.add_argument("--start-maximized") options.add_experimental_option('excludeSwitches', ['enable-logging']) options.add_argument('--headless') options.add_argument('--disable-gpu') options.add_argument('--disable-dev-shm-usage') options.add_argument('--no-sandbox') options.add_argument('--ignore-certificate-errors') options.add_argument( '--user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36"' ) # chrome_options.add_argument("--window-size=1920x1080") # options=options driver = Chrome(Browser_path, options=options) # else: # raise Exception(f'"{config_browser}" is not a supported browser') # Wait implicitly for elements to be ready before attempting interactions driver.implicitly_wait(config_wait_time) driver.maximize_window() # Return the driver object at the end of setup yield driver # For cleanup, quit the driver driver.quit()
def environment_setup(): global driver path = "C:\\selenium\\chromedriver.exe" driver = Chrome(executable_path=path) driver.get("http://www.theTestingWorld.com/testings") # if page takes more than 1 sec it shows error driver.set_page_load_timeout(1) # this will wait for 20 sec after page load if element not find then shows error if find in 5 sec it gets executed. driver.implicitly_wait(20) driver.maximize_window() yield driver.close() # this yield will execute after test case
def test_ayush(self): driver = self.driver driver.get("https://twitter.com/home") username = driver.find_element_by_xpath( "/html/body/div/div/div/div[2]/main/div/div/div[2]/form/div/div[1]/label/div/div[2]/div/input" ) driver.implicitly_wait(10) password = driver.find_element_by_xpath( "/html/body/div/div/div/div[2]/main/div/div/div[2]/form/div/div[2]/label/div/div[2]/div/input" ) driver.implicitly_wait(10) username.send_keys("ayush_tamra") password.send_keys("") driver.implicitly_wait(10) login_button = driver.find_element_by_xpath( "/html/body/div/div/div/div[2]/main/div/div/div[2]/form/div/div[3]/div/div/span/span" ) login_button.click() driver.implicitly_wait(10) search = driver.find_element_by_xpath( "/html/body/div[2]/div/div/div[2]/main/div/div/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/form/div[1]/div/div/div[2]/input" ) search.click() # driver.find_element_by_xpath("//input[@value='']").clear() driver.find_element_by_xpath( "/html/body/div[2]/div/div/div[2]/main/div/div/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/form/div[1]/div/div/div[2]/input" ).send_keys("#URGENT") driver.find_element_by_xpath( "/html/body/div[2]/div/div/div[2]/main/div/div/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/form/div[1]/div/div/div[2]/input" ).send_keys(Keys.ENTER) driver.find_element_by_link_text("Latest").click() driver.find_element_by_id("tweet-text").click() driver.find_element_by_id("tweet-text").click() UserText = driver.find_element_by_xpath( "//div[@id='tweet-text']/span[4]").text
def test_01_add_dept(self): driver = self.driver driver.get("https://online.actitime.com/ssarangmath/login.do") lgn = LoginPage(driver) lgn.enter_username("*****@*****.**") lgn.enter_pwd("Shar@8971") lgn.click_login() driver.implicitly_wait(10) time.sleep(3) #Verify successful login pageTitle = self.driver.title self.assertEqual("actiTIME - Enter Time-Track", pageTitle, "Login not success")
def index(): if request.method == 'POST': try: jobString = request.form['jobstring'].split(' ') joinJobString = '-'.join(jobString) location = 'in-' + request.form['location'] getvars = {'Sort': 2} totaljobs_url = 'https://www.totaljobs.com/jobs' + '/' + joinJobString + '/' + location + '?' + urllib.parse.urlencode( getvars) print('totaljobs_url', totaljobs_url) # Assign Path Variables #GOOGLE_CHROME_PATH = '/app/.apt/usr/bin/google_chrome' #CHROMEDRIVER_PATH = '/app/.chromedriver/bin/chromedriver' # Set the Chrome Options chrome_options = webdriver.ChromeOptions() driver = webdriver.Chrome(chrome_options=chrome_options) #chrome_options = webdriver.ChromeOptions() #chrome_options.binary_location = os.environ.get("GOOGLE_CHROME_BIN") #chrome_options.add_argument('--disable-gpu') #chrome_options.add_argument('--disable-dev-shm-usage') #chrome_options.add_argument('--no-sandbox') #chrome_options.add_argument('--headless') #chrome_options.binary_location = GOOGLE_CHROME_PATH # Build the Browser #driver = webdriver.Chrome(executable_path=os.environ.get("CHROMEDRIVER_PATH"), chrome_options=chrome_options) driver.get(totaljobs_url) driver.implicitly_wait(30) source = driver.page_source driver.quit() html = bs(source, "html.parser") print("html", html) bigboxes = html.findAll("div", {"class": "col-sm-12"}) del bigboxes[0:3] print('Bigboxes', bigboxes) filename = joinJobString + ".csv" fw = open(filename, "w") headers = "Job Title, Company Name, Job Location, Job Posting Time, Job Link \n" fw.write(headers) job_details = [] for bigbox in bigboxes: try: job_title = bigbox.find("div", { "class": "job-title" }).a.text.strip() except: job_title = "No Title" try: company_name = bigbox.find_all( "div", {"class": "col-xs-12"})[1].ul.find( "li", { "class": "company" }).h3.a.text except: company_name = "No Company Name" if company_name == "No Company Name": try: company_name = bigbox.find("div", { "class": "col-xs-7 col-sm-8" }).ul.find("li", { "class": "company" }).h3.a.text except: company_name = "No Company Name" try: job_link = bigbox.find("div", { "class": "job-title" }).a['href'] except: job_link = "No Job Link" try: job_location = bigbox.find("div", { "class": "detail-body" }).div.div.ul.li.span.a.text except: job_location = "No Job Location" if job_location == "No Job Location": try: job_location = bigbox.find("div", { "class": "detail-body" }).div.div.ul.li.span.text.strip() except: job_location = "No Job Location" try: job_posting_time = bigbox.find("li", { "class": "date-posted" }).span.text.strip() except: job_posting_time = "No Job Posting Time" mydict = { "Job Link": job_link, "Job Title": job_title, "Company Name": company_name, "Job Location": job_location, "Job Posting Time": job_posting_time } job_details.append(mydict) print('Job Details', job_details) keyValList = ["No Job Link"] Job_List = list( filter(lambda x: x['Job Link'] not in keyValList, job_details)) print('Job List', Job_List) return render_template('results.html', Total_Jobs=Job_List[0:(len(Job_List) - 1)]) except Exception as e: print('The Exception message is: ', e) return 'something is wrong' else: return render_template('index.html')
from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import WebDriverWait totalcount = [4779] for i in range(1, 68): # 카테고리에서 검색되는 음식점 수를 range로 잡기 # i=1로 시작할 것 print("count", i) driver = webdriver.Chrome( '/Users/Administrator/Downloads/chromedriver_win32/chromedriver') driver.get('https://www.yogiyo.co.kr/mobile/#/') driver.implicitly_wait(4) elem = driver.find_element_by_name('address_input') elem.clear() driver.implicitly_wait(4) elem.send_keys('서울 송파구 방이동') elem.send_keys(Keys.ENTER) time.sleep(0.3) driver.implicitly_wait(4) category = driver.find_element_by_xpath('//*[@id="category"]/ul/li[10]') # li[5]부터가 우리가 취급하는 첫 카테고리(치킨) driver.execute_script("arguments[0].click();", category) # 카테고리 클릭하는 코드. driver.implicitly_wait(4) body = driver.find_element_by_tag_name("body") down_n = 10
def test_demo(self): driver.implicitly_wait(10)