Exemplo n.º 1
0
def send_message(message, name):
    try:
        # change button xpath in case of non-friends
        time.sleep(1)
        driver.find_element_by_xpath(MESSAGE_BTN_XPATH).click()
        time.sleep(2)
        message_input = driver.switch_to.active_element
        message_input.send_keys(message.format(name))
        message_input.submit()
        print("Sent message to " + name + "...")
        return True
    except Exception:
        print("Could not send message to " + name + " :-(")
        return False
Exemplo n.º 2
0
def main():
    print("Welcome to ColdLink v1! The script is starting...")
    sent_messages = 0
    total_messages = 0

    login()

    with open('leads.txt') as leads:
        lead = leads.readline()
        time.sleep(3)
        while lead:
            navigate_to_profile(lead)
            name = driver.find_element_by_xpath(FULL_NAME_XPATH).text
            was_sent = send_message(MESSAGE, name)
            if was_sent:
                sent_messages += 1
            total_messages += 1
            time.sleep(3)
            lead = leads.readline()

    time.sleep(3)
    print("Done! Sent {} messages out of {}".format(sent_messages,
                                                    total_messages))
    driver.close()
Exemplo n.º 3
0
'''
Created on Oct 13, 2017

@author: Dell lap
'''
from drivers import driver
import time
driver.get("http://localhost/mystore/admin")

login = driver.find_element_by_id('input-username')
password = driver.find_element_by_id('input-password')
button = driver.find_element_by_xpath('//button')

login.send_keys("admin")
password.send_keys("admin")
button.click()

time.sleep(10)
driver.quit()
Created on Oct 11, 2017
@author: Dell lap
'''

from drivers import driver
import time
driver.get("http://localhost/seleniumtrials/formelements.html")
# get the current window handle

print driver.title

#get all the handles
primary_handle = driver.current_window_handle
print primary_handle

driver.find_element_by_xpath("//button[text()='Try it']").click()

afterclick = driver.current_window_handle
print afterclick

handles = driver.window_handles
#switch to the newly created handle
for handle in handles:
    if handle != primary_handle:
        driver.switch_to.window(handle)
        driver.maximize_window()
        time.sleep(5)
        driver.close()

driver.switch_to.window(primary_handle)
time.sleep(5)
from selenium.common.exceptions import *
# open make mytrip
driver.get("https://www.makemytrip.com/")
driver.implicitly_wait(0.5)

# implicit wait

# autocompletion from new delhi
#//input[@id='hp-widget__sfrom
#//div[contains(@class, 'locationFilter autocomplete_from')]//span[contains(text(),'New Delhi')]

from_city = driver.find_element_by_id('hp-widget__sfrom')
from_city.send_keys("New")

newdelhi = driver.find_element_by_xpath(
    "//div[contains(@class, 'locationFilter autocomplete_from')]//span[contains(text(),'New Delhi')]"
)
newdelhi.click()

# enter Kolkata
#//input[@id='hp-widget__sTo']
#//div[contains(@class, 'locationFilter autocomplete_to')]//span[contains(text(),'Mumbai')]

to_city = driver.find_element_by_id('hp-widget__sTo')
to_city.send_keys("Mumbai")

mumbai = driver.find_element_by_xpath(
    "//div[contains(@class, 'locationFilter autocomplete_to')]//span[contains(text(),'Mumbai')]"
)
mumbai.click()
Exemplo n.º 6
0
def login():
    driver.get(SIGN_IN_URL)
    driver.find_element_by_id(USERNAME_ID).send_keys(username)
    driver.find_element_by_id(PASSWORD_ID).send_keys(password)
    driver.find_element_by_xpath(SUBMIT_XPATH).click()
Exemplo n.º 7
0
'''
Created on Oct 12, 2017

@author: Dell lap
'''
from drivers import driver
from selenium.webdriver import ActionChains
import time
driver.get("http://localhost/mystore")
# get desktop element
# //a[contains(text(), 'Desktops')]
desktop = driver.find_element_by_xpath("//a[contains(text(), 'Desktops')]")
# create actions
action = ActionChains(driver)
# move to the element => mouse move != mouse click
action.move_to_element(desktop)
action.perform()
action.click(driver.find_element_by_partial_link_text("PC"))
action.perform()
#perform()
# perform is necessary

time.sleep(5)
driver.quit()