Hello I got an issue to make it work. I was able to make this working for the single automation, but now I want to do the for loop just to add multiple links into the form. Basically, I would like to take from .csv file with links. After adding first link, second row is copied and used search.send_keys("element"). Many thanks for suggestions
First code works as a single input.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import ActionChains
options = Options()
options.add_argument("--user-data-dir=/users/sb/Documents/UserData")
options.page_load_strategy = 'normal'
driver = webdriver.Chrome(options=options)
driver.get("database for links")
time.sleep(5)
search = driver.find_element("id", "link box")
search.send_keys("link to be added")
search.send_keys(Keys.RETURN)
#waiting for adding the link
time.sleep(20)
#End
search = driver.find_element("id", "modalclose").click()
Iteration implantation, which is not working
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import ActionChains
import xlrd
data_from_excel('/users/user/Downloads/links.csv.xls')
data_list = []
data = xlrd.open_workbook('/users/user/Downloads/links.csv.xls')
sheet = data.sheet_by_index(0)
sheet.cell_value(0, 0)
for i in range(sheet.nrows):
data_list.append(sheet.cell_value(i, 0))
return data_list
for element in data_list:
options = Options()
options.add_argument("--user-data-dir=/users/sb/Documents/UserData")
options.page_load_strategy = 'normal'
driver = webdriver.Chrome(options=options)
driver.get("link to the form")
time.sleep(5)
search = driver.find_element("id", "link box")
search.send_keys("element")
search.send_keys(Keys.RETURN)
#waiting for adding the link
time.sleep(10)
#end
search = driver.find_element("id", "modalclose").click()