Looping in Python

I need to set a loop. I need to set the loop from
tr[1] to tr[10] and every time I need to get back to the dashboard. Please help me doing this.
driver.find_element(By.XPATH, (‘/html/body/div/div[3]/table[1]/tbody/**tr[1]/**td[8]/a’)).click();

#Here is the code

driver.find_element(By.XPATH, ('/html/body/div/div[3]/table[1]/tbody/tr[1]/td[8]/a')).click();
driver.find_element(By.XPATH, ('//*[@id="tabPayment"]')).click();

driver.find_element(By.XPATH, ('/html/body/div/div[3]/div[4]/div[1]/ul/li[3]/a')).click();

driver.find_element(By.XPATH, ('/html/body/div/div[3]/div[4]/table/tbody/tr[2]/td[3]/a')).click();

driver.find_element(By.XPATH, ('/html/body/div/div[3]/table[2]/tbody/tr[2]/td[4]/a')).click();


#Extracting Data

headers = {
   "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0",
   "Accept-Encoding": "*",
   "Connection": "keep-alive",
}
page = driver.page_source

soup = BeautifulSoup(page,'html.parser')

TID = soup.find(text= "Tender/Proposal ID :").findNext('td')

print("TID=", TID.text)

#Getting Back to Dashboard
movemouse = driver.find_element(By.XPATH,"//a[@id='headTabEval']");
achains = ActionChains(driver)
achains.move_to_element(movemouse).perform()
time.sleep(1)
dashboard_url = driver.find_element(By.XPATH,"//a[normalize-space()='Evaluation Committee']").click();
time.sleep(5)

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Sounds like the perfect job for a for loop:

https://www.w3schools.com/python/python_for_loops.asp

for x in range(1,11):
  print(x)

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.