Ejemplo n.º 1
0
 def click_logout(self):
     '''This method clicks on the logout option'''
     try:
         WebDriverWait(self.driver, config.driver_wait).until(
             ec.visibility_of(
                 self.driver.find_element_by_css_selector(
                     self._menu_options)))
         print('Menu options found')
         ele_options = self.driver.find_elements_by_css_selector(
             self._menu_options)
         for ele in ele_options:
             print(ele)
             option = ele.text
             print(option)
             if option == 'Log Out':
                 ele.click()
                 break
         WebDriverWait(self.driver, config.driver_wait).until(
             ec.presence_of_element_located(By.CSS_SELECTOR(self._log_out)))
         user_text = self.driver.find_elements_by_xpath(self._log_out)
         for text in user_text:
             if text.text == '//logout':
                 print('Logout test passed')
             else:
                 print('Logout test failed')
     except Exception as e:
         print('Menu options not found', e)
Ejemplo n.º 2
0
class Browse:
    def __init__(self, driver):
        self.driver = driver

    signin = By.CSS_SELECTOR("a.login")
    loginemail = By.ID("email")
    loginpassword = By.ID("passwd")
    loginsubmit = By.ID("SubmitLogin")
    menu = By.XPATH("//div[@id='block_top_menu']/ul/li/a")
    searchbar = By.ID("search_query_top")

    def login(self):
        return self.driver.find_element(*Browse.signin).click()

    def logemail(self):
        return self.driver.find_element(*Browse.loginemail).send_keys("*****@*****.**")

    def logpassword(self):
        return self.driver.find_element(*Browse.loginpassword).send_keys("Sindhu124")

    def logsubmit(self):
        return self.driver.find_element(*Browse.loginsubmit).click()

    def search(self):
        return self.driver.find_element(*Browse.searchbar).send_keys("printed")

    def searchenter(self):
        return self.driver.find_element(*Browse.searchbar).send_keys(Keys.ENTER)
Ejemplo n.º 3
0
def test_add_to_cart(driver):
    auth(driver)
    count = 1
    while int(count) < 3:
        driver.find_element_by_css_selector('div.content img.image').click()
        time.sleep(2)
        if len(
                driver.find_elements_by_css_selector(
                    'a.main-image.fancybox.zoomable.shadow > div.sticker.sale')
        ) > 0:
            time.sleep(2)
            driver.find_element_by_css_selector(
                'select[name="options[Size]"] > option[value="Small"]').click(
                )
            time.sleep(2)
            driver.find_element_by_css_selector(
                'button[name="add_cart_product"]').click()
            # time.sleep(2)
            wait.until(
                EC.text_to_be_present_in_element(
                    By.CSS_SELECTOR('a.content span.quantity'), str(count)))
            count = driver.find_element_by_css_selector(
                'span.quantity').get_attribute('innerText')
            driver.get("http://litecart/en/")
        else:
            driver.find_element_by_css_selector(
                'button[name="add_cart_product"]').click()
            # time.sleep(2)
            wait.until(
                EC.text_to_be_present_in_element(
                    By.CSS_SELECTOR('a.content span.quantity'), str(count)))
            count = driver.find_element_by_css_selector(
                'span.quantity').get_attribute('innerText')
            driver.get("http://litecart/en/")
    driver.find_element_by_css_selector(
        'a.link[href="http://litecart/en/checkout"]').click()
    driver.find_element_by_css_selector(
        'button[name="remove_cart_item"]').click()
    driver.refresh()
    driver.find_element_by_css_selector(
        'button[name="remove_cart_item"]').click()
    driver.refresh()
    driver.find_element_by_css_selector(
        'button[name="remove_cart_item"]').click()
    driver.get("http://litecart/en/")
    time.sleep(5)
Ejemplo n.º 4
0
 def test_javascriptexecuter(self):
     ss_path = alist[4]
     driver = self.driver
     self.driver.get(alist[0])
     searchtext=driver.find_element(By.id("twotabsearchtextbox"))
     searchtext.send_keys("Mobiles")
     gobutton= driver.find_element(By.CSS_SELECTOR("input[value=Go]"))
     safeJavaScriptclick(gobutton)
Ejemplo n.º 5
0
 def Captcha_Crack(self):
     time.sleep(2)
     imglab = self.wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '.code.W_fl')))
     imageURL = self.findElement(By.CSS_SELECTOR(".code.W_fl img")).getAttribute("src")
     imgfile = dirname(abspath(__file__)) + '/captcha.png'
     byte = requests.get(imageURL, headers={'User-Agent': 'Mozilla/5.0'})
     with open(imgfile, 'wb') as f:
         f.write(byte.content)
     chaojiying = Chaojiying_Client('dongxuxiang', 'dxx15950092787', '898583')
     Img = open(imgfile, 'rb').read()
     CAPTCHA = chaojiying.PostPic(Img, 1902)['pic_str']
     Input = self.findElement(By.CSS_SELECTOR(".input_wrap.W_fl input"))
     Input.send_keys(CAPTCHA)
     login = self.findElement(By.CSS_SELECTOR(".W_btn_a.btn_32px"))
     login.click()
     if WebDriverWait(self.browser, 5).until(EC.text_to_be_present_in_element((By.CSS_SELECTOR, 'span[node-type="text"]'), '用户名或密码错误。查看帮助')):
         return 2
     else:
         if WebDriverWait(self.browser, 5).until(EC.text_to_be_present_in_element((By.CSS_SELECTOR, 'span[node-type="text"]'), '输入的验证码不正确')):
             return None
         else:
             return 1
Ejemplo n.º 6
0
def GetFollowers(browser):
    listOfFollowers = []
    browser.get('https://www.instagram.com/' +
                open('LoginInfo.txt').readlines()[0][0:-1])
    time.sleep(0.250)
    iGClick = browser.find_element(
        By.XPATH, '/html/body/span/section/main/div/header/section/ul/li[2]/a')
    iGClick.click()
    scroll = browser.find_element(By.XPATH, '/html/body')
    iGFollowers = browser.find_elements(By.CLASS_NAME, 'uu6c_')
    for i in range(20):
        scroll.send_keys(Keys.PAGE_DOWN)
        time.sleep(0.500)
    print(len(iGFollowers))
    for i in range(len(iGFollowers)):
        iGFollowersName = browser.find_elements(
            By.CSS_SELECTOR('//html/body/div[3]/div/div/div[2]/ul[1]/div/li[' +
                            str(i) + ']/div/div[2]/div[1]/div[1]'))
        iGFollowersButton = browser.find_elements(
            By.CSS_SELECTOR('/html/body/div[3]/div/div/div[2]/ul[1]/div/li[' +
                            str(i) + ']/div/div[2]'))
        listOfFollowers[i] = [iGFollowersName, iGFollowersButton]
    return listOfFollowers
Ejemplo n.º 7
0
def main(caseNumber, browser):

    elemSearch = browser.find_element_by_id("phSearchInput")
    elemSearch.send_keys(caseNumber)

    browser.find_element_by_id("phSearchButton").submit()
    lk.wait(2)

    # elemTag = browser.find_elements_by_tag_name("td")
    # elemTag = browser.find_elements_by_class_name("dataCell")
    elemTag = browser.find_element(By.CSS_SELECTOR("input[name='dataDell'] a"))
    # elemTag1 = elemTag[1].find_element_by_tag_name("a")
    print("Elem.tag :{}".format(str(elemTag)))
    print(modNm + "elemTag1: {}".format(elemTag))
    elemTag.click()
Ejemplo n.º 8
0
    def webTest(self):
        driverLocation = "D:\\Python\\Files\\chromedriver.exe"
        os.environ["webdriver.chrome.driver"] = driverLocation
        driver = webdriver.Chrome(driverLocation)
        baseurl = "http://cgsd.oemsbd.com:2019"
        driver.get(baseurl)
        driver.maximize_window()
        driver.implicitly_wait(50)

        username = driver.find_element_by_xpath("//input[@name='Email']")
        username.send_keys("admin")
        password = driver.find_element_by_xpath("//input[@name='Password']")
        password.send_keys("hG41C440")
        login = driver.find_element_by_xpath(
            "//button[@class='btn red btn-block uppercase']")
        login.click()
        # studentEntry=driver.find_element_by_xpath("//*[@id='accordion']/li[2]/div")
        #studentEntry.click()
        #quickaddstudent= driver.find_element_by_xpath("//*[@id='accordion']/li[2]/ul/li[1]/a/span")
        #quickaddstudent.click()
        inventory = driver.find_element_by_xpath(
            "//ul[@id='pills-tab']//a[@href='/InventoryV/Dashboard']")
        inventory.click()
        setup = driver.find_element_by_xpath(
            "//ul[@id='accordion']/li[2]/div/a[@href='#']/span[.='SetUp']")
        setup.click()
        unit = driver.find_element_by_xpath(
            "//ul[@id='accordion']/li[2]/ul//a[@href='/InventoryV/UnitSetup']/span[.='Unit Setup']"
        )
        unit.click()
        #addnew=driver.find_element_by_xpath("//button[@ng-click='resetForm()']")
        #addnew.click()
        try:
            WebDriverWait(driver, 20).until(
                ec.element_to_be_selected(
                    (By.CSS_SELECTOR('.btn-group-solid [data-target]s')
                     ))).click()
        finally:
            driver.quit()
        #unit_name= driver.find_element_by_xpath("//input[@name='CategoryName']")
        #unit_name.send_keys("newly added unit")
        #code=driver.find_element_by_xpath("//input[@name='code']")
        #code.send_keys("1234567")
        #save=driver.find_element_by_xpath("//button[@type='submit']")
        #save.click()
        time.sleep(5)
Ejemplo n.º 9
0
def login(name, password):
    url = "https://login.taobao.com/member/login.jhtml"
    browser.get(url)
    wait.until(
        EC.presence_of_element_located(
            By.CSS_SELECTOR("div.login-switch #J_Quick2Static"))).click()
    browser.find_element_by_id("TPL_username_1").send_keys(name)
    browser.find_element_by_id("TPL_password_1").send_keys(password)
    time.sleep(1)
    try:
        slider = browser.find_element_by_css_selector("#nc_1_n1z")
        action = ActionChains(browser)
        action.drag_and_drop_by_offset(slider, 500, 0).perform()
        time.sleep(3)
    except Exception as e:
        pass
    time.sleep(2)
    browser.find_element_by_id("J_SubmitStatic").click()
Ejemplo n.º 10
0
 def fluentWaitElementByCss(location):
     try:
         element = WebDriverWait(location.driver, 10).until(
             EC.presence_of_element_located((By.CSS_SELECTOR(location))))
     finally:
         location.driver.quit()
Ejemplo n.º 11
0
class Account:
    def __init__(self, driver):
        self.driver = driver

    signin = By.CSS_SELECTOR("a.login")
    account_email = By.ID("email_create")
    create_account = By.ID("SubmitCreate")
    first_name = By.ID("customer_firstname")
    last_name = By.ID("customer_lastname")
    password = By.ID("passwd")
    address = By.ID("address1")
    city = By.ID("city")
    zipcode = By.ID("postcode")
    states = By.XPATH("//*[@id='id_state']/option[5]")
    phone_number = By.ID("phone_mobile")
    address_alias = By.ID("alias")
    register = By.ID("submitAccount")

    def signing(self):
        return self.driver.find_element(*Account.signin).click()

    def sendemail(self):
        return self.driver.find_element(
            *Account.account_email).send_keys("*****@*****.**")

    def createaccount(self):
        return self.driver.find_element(*Account.create_account).click()

    def firstnamesend(self):
        return self.driver.find_element(
            *Account.first_name).send_keys("Sindhu")

    def lastnamesend(self):
        return self.driver.find_element(*Account.last_name).send_keys("Sh")

    def passwordsend(self):
        return self.driver.find_element(
            *Account.password).send_keys("Sindhu124")

    def addresssend(self):
        return self.driver.find_element(
            *Account.address).send_keys("2421 carlmont")

    def citysend(self):
        return self.driver.find_element(*Account.city).send_keys("Belmont")

    def statesend(self):
        return self.driver.find_element(*Account.states).click()

    def zipcodesend(self):
        return self.driver.find_element(*Account.zipcode).send_keys("94002")

    def phonesend(self):
        return self.driver.find_element(
            *Account.phone_number).send_keys("6504036567")

    def addressaliassend(self):
        return self.driver.find_element(
            *Account.address_alias).send_keys("Bangalore India")

    def registered(self):
        return self.driver.find_element(*Account.register).click()
Ejemplo n.º 12
0
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver

browser = webdriver.Chrome()
link = 'http://suninjuly.github.io/explicit_wait2.html'
browser.get(link)
'''
# говорим Selenium проверять в течение 5 секунд, пока кнопка не станет кликабельной
button = WebDriverWait(browser, 5).until
                    EC.element_to_be_clickable((By.ID, "check"))
                    )
'''
button = browser.find_element(By.CSS_SELECTOR("button#book"))
button.click()

#message = browser.find_element_by_id("check_message")

#assert "успешно" in ../log/message.text
Ejemplo n.º 13
0
""" K ABDUL VASEEM AKRAM """

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By


driver = webdriver.Chrome(r'D:\New folder\Abdul\chromedriver.exe')
driver.get(r"https://web.whatsapp.com/")
string title = "Hanish"
message="hai Hanish ,how are you?"

driver.findElement(By.CSS_SELECTOR("[title^='"+title+"']")).click();

inp_xpath = '[@dir="auto"][@data-tab="1"]'
input_box = wait.until(EC.presence_of_element_located(( 
    By.XPATH, inp_xpath)))
for i in range(50): 
    input_box.send_keys(string + Keys.ENTER) 
    time.sleep(5)
Ejemplo n.º 14
0
 def select_group_by_id(self, elem_id):
     self.find_element(By.CSS_SELECTOR("input[value='" + elem_id + "']")).click()
Ejemplo n.º 15
0
import time
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome(executable_path='D:\Drivers\chromedriver.exe')
driver.implicitly_wait(5)      #implicit wait
driver.maximize_window()
driver.get('https://www.expedia.com')
driver.find_element(By.ID,'tab-flight-tab-hp').click()
time.sleep(2)      #Python wait function

'''from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as object1
driver.wait1 = WebDriverWait(driver,10)
element = driver.wait1.until(object1.presence_of_element_located((By.ID,'flight-type-multi-dest-label-hp-flight')))
driver.find_element(By.ID,'flight-type-multi-dest-label-hp-flight').click()

driver.get('https://www.extrahop.com')
print(driver.title)

driver.wait = WebDriverWait(driver,5)
driver.wait.until(object1.element_to_be_clickable((By.ID,'wistia_29.thumb_container')))
driver.find_element_by_id('wistia_29.thumb_container').click()'''

driver.get('http://newtours.demoaut.com/mercuryregister.php')
ele= driver.find_elements(By.CSS_SELECTOR("input['maxlength'='64']"))
print(len(ele))

time.sleep(2)
driver.quit()