def login():
    # navigate to the application home page
    driver.get("https://www.mercadona.es/ns/entrada.php?js=1")
    username = driver.find_element_by_id("username")
    username.clear()
    username.send_keys(config["username"])
    password = driver.find_element_by_id("password")
    password.clear()
    password.send_keys(config["password"])
    username.submit()
    time.sleep(1)
    try:
        alert = driver.switch_to_alert().text
        return False
    except NoAlertPresentException:
        return True
def click_on_next():
    try:
        next_page = driver.find_element_by_id("NEXT")
        if next_page and next_page.is_displayed():
            next_page.click()
            time.sleep(2)
            return True
        return False
    except NoSuchElementException:
        return False
def enter_search(term):
    current_handle = driver.current_window_handle
    driver.switch_to.window(current_handle)
    driver.switch_to.frame("toc")
    driver.switch_to.frame("topbusc")
    search_field = driver.find_element_by_id("busc_ref")
    search_field.clear()
    search_field.send_keys(term + Keys.ENTER)
    driver.switch_to.window(current_handle)
    driver.switch_to.frame("mainFrame")
Пример #4
0
# Gets inside LinkedIn
driver.get(url)
sleep(0.5)

# Accepting cookies
driver.find_element_by_xpath(
    '//*[@id="artdeco-global-alert-container"]/div[1]/section/div/div[2]/button[2]'
).click()
sleep(0.5)
# Clicks login button
click_login_button = driver.find_element_by_xpath(
    '/html/body/nav/div/a[2]').click()

# Finds email and password input fields and it sends the respective
email_input = driver.find_element_by_id('username')
email_input.send_keys(email)
sleep(0.5)

password_input = driver.find_element_by_id('password')
password_input.send_keys(password)
sleep(0.5)

driver.find_element_by_xpath(
    '//*[@id="organic-div"]/form/div[3]/button').click()
sleep(3)

driver.find_element_by_class_name('msg-overlay-bubble-header').click()
sleep(0.5)

driver.find_element_by_link_text('Jobs').click()
Пример #5
0
from selenium_driver import driver
from time import time, sleep

cookie_clicker_game_url = 'http://orteil.dashnet.org/experiments/cookie/'
driver.get(cookie_clicker_game_url)

initial_store = driver.find_elements_by_class_name('grayed')
cookie_object = driver.find_element_by_id('cookie')

initial_time = time()
while True:
    current_time = time()
    new_store = driver.find_elements_by_class_name('grayed')
    cookie_object.click()

    if current_time - initial_time > 5 and len(initial_store) != len(
            new_store):
        index_to_pick = (len(initial_store) - len(new_store)) - 1
        click_item = initial_store[index_to_pick].click()
        sleep(1)
        initial_time = current_time
        initial_store = new_store
Пример #6
0
# Click Login
sleep(1)
driver.find_element_by_xpath('//span[text()="Log in"]').click()

# Login with Facebook
sleep(1)
driver.find_element_by_xpath('//span[text()="Log in with Facebook"]').click()
sleep(1)

# We targetting the popup here by making the selenium switch to the second window.
# This is how it's done, we first make driver handle first window then switch to that window.
facebook_window = driver.window_handles[1]
driver.switch_to.window(facebook_window)

# We getting the email and pass id from them and sending our credentials
email_input = driver.find_element_by_id('email')
email_input.send_keys(email)

password_input = driver.find_element_by_id('pass')
password_input.send_keys(password)

driver.find_element_by_id('loginbutton').click()

# We going back to the main tinder app here
base_window = driver.window_handles[0]
driver.switch_to.window(base_window)
sleep(5)

# Accepting the conditions if appeared
allow_tinder_location = driver.find_element_by_xpath(
    '//span[text()="Allow"]').click()
Пример #7
0
from selenium_driver import driver
amazon_url = 'https://www.amazon.es/Huawei-Matebook-D15-Multi-Screen-Collaboration/dp/B083V6LT1T/ref=pd_day0_2?pd_rd_w' \
             '=PD3a8&pf_rd_p=0ff21a3e-4297-4047-87ec-ba06b6bc995e&pf_rd_r=K80J9VPE80R3PTN64J0G&pd_rd_r=9d94802a-885f-4' \
             'b9e-8935-1672639d291a&pd_rd_wg=tkcrg&pd_rd_i=B083V6LT1T&psc=1'

driver.get(amazon_url)
deal_price = driver.find_element_by_id('priceblock_ourprice')
print(deal_price.text)

driver.close()
Пример #8
0
from selenium_driver import driver
from fetch_quote import quote, author
import time
import datetime as dt

driver.get(
    'https://quotescover.com/designs/wording?res=UFg2ajdxa2FRQ3hIa0VrZGc5dEE0Zz09'
)
driver.find_element_by_id("quotes").send_keys(quote)
driver.find_element_by_id("author").send_keys(author)
driver.find_element_by_id("template-contactform-submit").click()

time.sleep(3)

driver.find_element_by_xpath(
    "//div[@class='forDesktop']/div/button[@onclick='openDownload()']").click(
    )

time.sleep(15)

driver.find_element_by_xpath('''//button[@onclick="openNav('jpg')"]''').click()

time.sleep(3)

now = dt.datetime.now()
fileName = "quote_" + now.strftime("%d_%H_%M_%S")
driver.find_element_by_id("fileName").send_keys(fileName)

time.sleep(3)

driver.find_element_by_xpath(