So I have a program that opens as multiple windows as the number of XLSX file entered. For example, If user browse 5 XLSX file, Selenium opens 5 WordPress new post page.
But I want it to write these files each one to each window. Here is my while loop.
def selenium_process():
driver = webdriver.Chrome(data[3])
x = 0
#Opening the first window for logging in.
driver.get(data[0])
driver.find_element_by_id("user_login").send_keys(data[1])
driver.find_element_by_id("user_pass").send_keys(data[2])
driver.find_element_by_id("wp-submit").click()
#Sending a random Title string for test.
driver.find_element_by_xpath("/html/body/div[1]/div[2]/div[2]/div[1]/div[3]/form/div/div/div[1]/div[1]/div[1]/input").send_keys("Hello")
#Opening other windows
while x <= postCount - 2:
driver.execute_script(f"window.open('{data[0]}');")
driver.find_element_by_xpath("/html/body/div[1]/div[2]/div[2]/div[1]/div[3]/form/div/div/div[1]/div[1]/div[1]/input").send_keys("New Windows")
x = x + 1
if(x>postCount - 2):
time.sleep(10000000)
(I'm getting postCount variable from the counts of XLSX files)
How can I fix that? Any ideas?
Thanks much.