Mozilla Firefox
0
Вклад в тег
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
import datetime
import time
import random
from datetime import datetime
from random import randint
from random import choice
from string import ascii_lowercase
from string import digits
import os
import shutil
from shutil import copytree, ignore_patterns
def regger():
count = 1
login = 'testprofile2@mail.com'
shutil.copytree('/home/user/.mozilla/firefox/source/', "/home/user/.mozilla/firefox/"+ str("source") + str(count))
profile = "/home/user/.mozilla/firefox/source" + str(count)
fp = webdriver.FirefoxProfile(profile)
# Addons
directory = '/home/user/ffadns/'
files = os.listdir(directory)
addon = directory + str(random.choice(files)); addon2 = directory + str(random.choice(files)); addon3 = directory + str(random.choice(files))
fp.add_extension(addon); fp.add_extension(addon2); fp.add_extension(addon3)
addon_name = addon.split('/'[-1]) ; addon2_name = addon2.split('/'[-1]); addon3_name = addon3.split('/'[-1])
driver = webdriver.Firefox(fp)
dd = fp.profile_dir.split('/')
tempProfile_name = dd[-2]
shutil.move('/tmp/' + str(tempProfile_name) + '/webdriver-py-profilecopy/', '/tmp/' + str(login))
shutil.copytree('/tmp/' + login, '/home/user/.mozilla/firefox/' + login, ignore=ignore_patterns('lock'))
shutil.rmtree('/home/user/.mozilla/firefox/source1')
driver.quit()