0

I want to run my code 10 times in 10 new tabs. Kindly help me on how can I use a for loop and open in 10 different tabs.

code;

import time

from selenium import webdriver
from selenium.webdriver.chrome.options import Options



opt = Options()
opt.add_argument("--disable-infobars")
opt.add_argument("start-maximized")
opt.add_argument("--disable-extensions")
# Pass the argument 1 to allow and 2 to block
opt.add_experimental_option("prefs", {
    "profile.default_content_setting_values.media_stream_mic": 1,
    "profile.default_content_setting_values.media_stream_camera": 1,
    "profile.default_content_setting_values.geolocation": 1,
    "profile.default_content_setting_values.notifications": 1
  })

driver = webdriver.Chrome(options=opt, executable_path="C:\\chromedriver.exe")

driver.implicitly_wait(5)
driver.get("https://virtual.eventbuizz.com/event/what-is-app-virtualization--part-1--remote-apps-8862/streaming")

driver.find_element_by_xpath("//input[@type='text']").send_keys("aha@eventbuizz.com")
driver.find_element_by_css_selector("[class='btn btn-default btn-submit']").click()
time.sleep(4)
driver.find_element_by_xpath("//a[@class='slidebox sliboxtheme_3']").click()
driver.find_element_by_xpath("//button[contains(text(),'Ja')]").click()
driver.find_element_by_css_selector("div[class='app-main-content-area h-100'] button:nth-child(2)").click()
driver.find_element_by_css_selector(".false.icon-play-pause").click()
time.sleep(3)
driver.find_element_by_xpath("//button[contains(text(),'Ja')]").click()

driver.find_element_by_xpath("//button[contains(text(),'Luk')]").click()
time.sleep(2)
driver.find_element_by_xpath("//div[contains(text(),'panel-dis')]").click()

Now, I use a manual way. Here is the code:

driver.execute_script("window.open('about:blank', 'tab2');") 
driver.switch_to.window("tab2") driver.implicitly_wait(5) 
driver.get("virtual.eventbuizz.com/event/…) time.sleep(2) 
driver.find_element_by_xpath("//div[contains(text(),'panel-dis')]").click() 
3
  • now i use manual way here is code ; driver.execute_script("window.open('about:blank', 'tab2');") driver.switch_to.window("tab2") driver.implicitly_wait(5) driver.get("virtual.eventbuizz.com/event/…) time.sleep(2) driver.find_element_by_xpath("//div[contains(text(),'panel-dis')]").click() Jun 17 at 10:25
  • Instead of adding a comment, you can edit your post to provide more clarity
    – Lee Jensen
    Jun 17 at 14:20
  • @PDHide kindly help Jun 18 at 6:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.