0
Hi, I need some help. I need this script I have (Python and JS) to open a certain number of tabs and after a time interval close and reopen the same tabs again. However, to not close the browser, I still need to always open one of them. For now I am in this code but for two days I have not left it. Note: I am using Selenium!
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import json
import sys
import os
import pyautogui
sys.path.append(os.getcwd())
arquivoConf = os.path.join(os.getcwd(), sys.argv[1])
with open(arquivoConf) as json_data_file:
config = json.load(json_data_file)
firefox_profile = webdriver.FirefoxProfile(config['from_nameFirefox'])
browser = webdriver.Firefox(firefox_profile)
num_of_tabs = 10
time.sleep(10)
while True:
t = len(browser.window_handles)
print (t)
for i in range(1, t):
browser.window_handles[i]
time.sleep(2)
print ( 'Fechando tab ' + str(i) )
for x in range(1, num_of_tabs):
browser.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 'w')
browser.execute_script('window.open("","_self").close()')
browser.execute_script('window.close()')
time.sleep(2)
Thank you friend for your attention but this code is not yet doing what I want. Actually I think it was my mistake because I need it to open several tabs or tabs in the same browser window. Not in multiple windows as shown. I am currently using this code (https://pastebin.com/XRHgmprS) if you can help I would appreciate it very much!
– Romulo Sousa