0

For example I have in PyCharm:

Script1.py

from selenium import webdriver
import time

PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://www.youtube.com/?hl=pl&gl=PL")
time.sleep(1)
driver.close()

Script2.py

import YtTest.py
import time

i = 0
while i < n:
    execfile("YtTest.py")
    i += 1

How to make import properly and execute Script1.py and loop it N times (all in Script2.py)?

  • What in Script1.py do you want to execute from Script2.py? – norie Feb 25 '21 at 18:54
  • Wrap it in a function and import the file with said function, call the function n times. Sorry, but you've not posted code, or told us what you've tried. –  Feb 25 '21 at 18:54
  • Have you checked https://stackoverflow.com/questions/1027714/how-to-execute-a-file-within-the-python-interpreter The suggested answers should do the job if performed in a loop – C Hecht Feb 25 '21 at 18:55

0 Answers0