selenium python wait

#!/usr/bin/python
import sys
import re
import os
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
import win32com.client
import win32api
import win32con
import datetime as dt
import cx_Oracle
from selenium.webdriver.common.by import By

env = "val01"
netsPayment = ""

if env == "test01" or env == "test1":
    ip = '127.0.50.10'
    port = 1521
    SID = 'ICIA1T'
    dsn_tns = cx_Oracle.makedsn(ip, port, SID)
    username = 'CISADM'
    password= 'Icisk2016'
    bawDKSKBP = "https://5.44.137.168:444/batch-administration-website/executeBatchJobManually?batchType=PSRM&batchId=197"
    bawDKNP = "https://5.44.137.168:444/batch-administration-website/executeBatchJobManually?batchType=PSRM&batchId=196"
    bawPEPL1 = "https://5.44.137.168:444/batch-administration-website/executeBatchJobManually?batchType=PSRM&batchId=184"
    bawPEPL2 = "https://5.44.137.168:444/batch-administration-website/executeBatchJobManually?batchType=PSRM&batchId=185"
    bawServer = "https://5.44.137.168:444"
elif env == "test02" or env == "test2":
    ip = '127.0.50.11'
    port = 1521
    SID = 'ICIA2T'
    dsn_tns = cx_Oracle.makedsn(ip, port, SID)
    username = 'CISADM'
    password= 'Icisk2016'
    bawDKSKBP = "https://5.44.137.168:451/batch-administration-website/executeBatchJobManually?batchType=PSRM&batchId=137"
    bawDKNP = "https://5.44.137.168:451/batch-administration-website/executeBatchJobManually?batchType=PSRM&batchId=196"
    bawPEPL1 = "https://5.44.137.168:451/batch-administration-website/executeBatchJobManually?batchType=PSRM&batchId=124"
    bawPEPL2 = "https://5.44.137.168:451/batch-administration-website/executeBatchJobManually?batchType=PSRM&batchId=125"
    bawServer = "https://5.44.137.168:451"


chromedriver = "C:\Python\chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
#if browser == 'chrome':
options = webdriver.ChromeOptions()

#options.add_argument("--start-maximized")
options.add_argument('--ignore-certificate-errors')
prefs = {
        "profile.default_content_settings.popups": 0,
        "download.default_directory": r"C:\Users\user_dir\Desktop\\", # IMPORTANT - ENDING SLASH V IMPORTANT
        "directory_upgrade": True,
        "download.prompt_for_download": False
        }
options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=options)
delay = 3 # seconds
#baw settings
username = "USERNAME"
password = "PASSWORD"

#Baw batchjob summary settings - will be used later
StartTime = dt.datetime.now().strftime('%Y-%m-%d' + 'T')
StartHour = dt.datetime.now().strftime('%H')
StartMin = dt.datetime.now().strftime('%M')
StartSec = dt.datetime.now().strftime('%S')

if netsPayment == "nets":
    #nets payment
    driver.get('https://' + username + ':' + password + '@' + bawDKNP.replace('https://',''))
    print ("Batch job: DKNP")
    driver.get('https://' + username + ':' + password + '@' + bawPEPL1.replace('https://',''))
    print ("Batch job: PEPL1")
    driver.get('https://' + username + ':' + password + '@' + bawPEPL2.replace('https://',''))
    print ("Batch job: PEPL2")
else:
    #cremul payment skb
    driver.get('https://' + username + ':' + password + '@' + bawDKSKBP.replace('https://',''))
    print ("Batch job: DKSKBP")
    driver.get('https://' + username + ':' + password + '@' + bawPEPL1.replace('https://',''))
    print ("Batch job: PEPL1")
    driver.get('https://' + username + ':' + password + '@' + bawPEPL2.replace('https://',''))
    print ("Batch job: PEPL2")
   
#Get summary status on baw
EndMin = dt.datetime.now().strftime('%M')
driver.get(bawServer + "/batch-administration-website/executedBatchJobs?start=" + StartTime + StartHour +"%3A" +StartMin + "%3A" + StartSec + "%2B02%3A00&end=" + StartTime + StartHour +"%3A" + EndMin + "%3A" + StartSec + "%2B02%3A00")


#driver.quit()
try:
    #Wait to load the dropdown as an indication of the page is "fully loaded"
    myElem = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.ID, 'datetimepicker1')))
    #element_present = EC.presence_of_element_located((By.ID, 'datetimepicker1'))
    #WebDriverWait(driver, timeout).until(element_present)
    print ("Page is ready!")
except TimeoutException:
    print ("Loading took too much time!")















http://selenium-python.readthedocs.io/waits.html

Kommentarer

Populære opslag fra denne blog

Xpath cheat sheet

Reading Email

pip whl install python