I want my for loop to take URLs one by one and hit and do some operations like, [clicking button and extracting text] first time when the URL is hit it needs uname, pwd and login from next time onwards no need credentials, it can directly just click button and extract URL.
Operational code : for clicking and extracting is working fine. only for loop has some issue
def lookup(driver,uname,pwd):
with open("A.txt") as f:
for line in f:
url = line.strip()
print("Getting %s" % url)
driver.get(url)
box = driver.wait.until(EC.presence_of_element_located((By.NAME, "j_username")))
box.send_keys(uname)
box = driver.wait.until(EC.presence_of_element_located((By.NAME, "j_password")))
box.send_keys(pwd)
button = driver.wait.until(EC.element_to_be_clickable((By.NAME, "login")))
button.click()
button = driver.wait.until(EC.presence_of_element_located((By.ID, "fetchCandidateChanges_0")))
button.click()
driver.wait = WebDriverWait(driver, 15)
time.sleep(15)
labels = driver.find_elements_by_xpath('//label[@class="pagebanner"]')
for label in labels:
print (label.text)
driver.get("content"). It should bedriver.get(content). And you missed a loop here as well, if you want to read all the URLs.