heading.execute_script("document.querySelector('div.s-item-title')[0].value='%s'" % h1_text)
Restarting Firefox
Firefox's memory usage may increase if it's left open for long periods of time. A workaround for this is to periodically restart Firefox.
about:memory
selenium-requests
from browsermobproxy import Server
server = Server("path/to/browsermob-proxy")
server.start()
proxy = server.create_proxy()
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_proxy(proxy.selenium_proxy())
driver = webdriver.Firefox(firefox_profile=profile)
proxy.new_har("гугл")
driver.get("http://www.гугл.рф")
proxy.har
server.stop()
driver.quit()
import os, time
os.environ['TZ'] = 'US/Eastern'
time.tzset()
var config = {
mode: "fixed_servers",
rules: {
singleProxy: {
scheme: "http",
host: "%proxy_host",
port: parseInt(%proxy_port)
},
bypassList: ["foobar.com"]
}
};
chrome.proxy.settings.set({value: config, scope: "regular"}, function() {});
function callbackFn(details) {
return {
authCredentials: {
username: "%username",
password: "%password"
}
};
}
chrome.webRequest.onAuthRequired.addListener(
callbackFn,
{urls: ["<all_urls>"]},
['blocking']
);
{
"version": "1.0.0",
"manifest_version": 2,
"name": "Chrome Proxy",
"permissions": [
"proxy",
"tabs",
"unlimitedStorage",
"storage",
"<all_urls>",
"webRequest",
"webRequestBlocking"
],
"background": {
"scripts": ["background.js"]
},
"minimum_chrome_version":"22.0.0"
}
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_extension("proxy_auth.zip")
driver = webdriver.Chrome(executable_path='chromedriver.exe', chrome_options=chrome_options)
Видим следующие проблемы при организации нового подразделения:
1) Огромное разнообразие вариантов построения продуктов из блоков конструктора - что работает у одного заказчика, может не сработать у другого по разным причинам. На какой конфигурации конструктора проводить тесты?
from selenium import webdriver
import time
from datetime import datetime
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver.get('https://www.toster.ru')
time.sleep(3)
driver.find_element_by_xpath('//a[@class="btn btn_green btn_add-question"]').click()
time1 = datetime.now()
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "//textarea[@class='field__input textarea']"))
)
finally:
time2 = datetime.now()
delta = time2 - time1
print(delta)