options.addArguments("profile-directory=Profile 2")
opt.AddArgument("--user-data-dir=C:\\user\\data\\dir");
mySelectElement = browser.find_element_by_id('providerTypeDropDown')
dropDownMenu = Select(mySelectElement)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//select[@id='providerTypeDropDown']//options[contains(.,'Professional')]")))
dropDownMenu.select_by_visible_text('Professional')
import time
from selenium import webdriver
class Test():
def __init__(self):
self.driver = webdriver.Chrome()
def test_case(self):
self.driver.get("https://stepik.org/lesson/25969/step/12")
time.sleep(5)
textarea = self.driver.find_element_by_css_selector(".textarea")
textarea.send_keys('get()')
time.sleep(1)
submit_button = self.driver.find_element_by_css_selector(".submit-submission")
submit_button.click()
time.sleep(3)
if __name__ == '__main__':
a = Test()
a.test_case()
import unittest
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
wait_time = 20 # seconds
class TestStepik(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.wait = WebDriverWait(self.driver, wait_time)
def tearDown(self):
self.driver.quit()
def test_submit_button(self):
self.driver.get("https://stepik.org/lesson/25969/step/12")
textarea = self.wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".textarea")))
textarea.send_keys('get()')
submit_button = self.driver.find_element_by_css_selector(".submit-submission")
submit_button.click()
self.wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".attempt-message_correct")))
if __name__ == '__main__':
unittest.main()
import clipboard
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
driver = webdriver.Chrome()
# Загружаем страницу
driver.get("https://yandex.ru/chat/#/chats/1%2F0%2Fccb05ef5-1472-4e50-a926-602807a6ef94")
balloons_xpath = "//div[contains(@class, 'yamb-message-balloon')]"
WebDriverWait(driver, 10).until(ec.presence_of_all_elements_located((By.XPATH, balloons_xpath)))
# Выбираем посты в канале
balloons = driver.find_elements_by_xpath(balloons_xpath)
# Кликаем на пост #4
actionChains = ActionChains(driver)
actionChains.context_click(balloons[4]).perform()
get_link_text = 'Get message link'
driver.find_element_by_xpath(f"//span[text()='{get_link_text}']/..").click()
# Получаем буфер обмена
text = clipboard.paste() # text will have the content of clipboard
print(text)
driver.quit()
https://yandex.ru/chat/#/join/33a66c77-0c4d-45be-80f6-cae89e95d765/1591340550272042
Process finished with exit code 0
from selenium import webdriver
from time import sleep
driver = webdriver.Chrome()
driver.get("https://rublix.best/")
prev_bet = 0
while True:
all_bets = driver.find_elements_by_xpath("//div[contains(@class, 'history-line')]")
if all_bets:
last_bet = all_bets[0].text
if last_bet != prev_bet:
prev_bet = last_bet
print(f'Last bet: {last_bet}')
sleep(1)
blocks = driver.find_elements_by_xpath("//*[contains(@class, 'd-inline-block')]")
for i, block in enumerate(blocks):
with open(file=f'{i}.png', mode='wb') as f:
f.write(block.screenshot_as_png)
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument(f"user-data-dir={profile_path}")
driver = webdriver.Chrome(options=chrome_options)
@daily rm -rf /tmp/.org.chromium.Chromium*
# Sleep before starting new loop
print ('Set pausa time')
for i in range(900, 0, -1):
sys.stdout.write(str(i) + ' ')
sys.stdout.flush()
time.sleep(1)
//*[@class='account-widget__username']
//div[@class='account-widget']//div[@class='account-widget__username']
chrome_options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.notifications" : 2}
chrome_options.add_experimental_option("prefs",prefs)
driver = webdriver.Chrome(chrome_options=chrome_options)
from selenium.common.exceptions import TimeoutException
...
except TimeoutException:
...
from selenium import webdriver
driver = webdriver.Firefox()