Beispiel #1
0
caps["automationName"] = "Appium"
caps["platformName"] = "android"
caps["platformVersion"] = "7.0"
caps["deviceName"] = "621QECQ93YHWU"  #设备名称 或 模拟器(如:127.0.0.1:62001)
# caps["deviceName"] = "360手机 N4S"
caps['appPackage'] = 'com.ifeixiu.flysender.debug'  #指定app
caps['appActivity'] = 'com.jxf.splashmodule.ui.SplashActivity'  #指定页面

#如果设置的是app在电脑上的路径,则不需要配appPackage和appActivity,同理反之

# appium 服务
driver = webdriver.Remote("http://0.0.0.0:4723/wd/hub", caps)

#获取元素并操作
# 地理位置权限
quanxian_1 = driver.find_element_by_id(
    'com.android.packageinstaller:id/permission_allow_button')
# print(switch)
quanxian_1.click()
#手机存储权限
quanxian_2 = driver.find_element_by_id(
    'com.android.packageinstaller:id/permission_allow_button')
# print(switch)
quanxian_2.click()

#拨打电话权限
quanxian_3 = driver.find_element_by_id(
    'com.android.packageinstaller:id/permission_allow_button')
# print(switch)
quanxian_3.click()

#手机识别码权限
    print "Url entered and website displayed"
else:
    print "Entered a wrong Url"

#To click Sign in button
sign_in_button = driver.find_element_by_link_text("Sign in")
if sign_in_button.is_enabled():
    sign_in_button.click()
    print("The wegpage is redirect to login page")
else:
    print("The webpage is not redirect to login page")

#Enter username, password and click sign in button
mandatory_field = driver.find_element_by_name("login")
mandatory_field.send_keys("testingpython")
mandatory_field = driver.find_element_by_id("password")
mandatory_field.send_keys("test1234")
sign_in_button = driver.find_element_by_name("commit")
sign_in_button.click()
text_found = driver.find_element_by_id("js-flash-container")
if text_found.text == "Incorrect username or password.":
    print(
        "Displaying message when entered username & password is wrong: Incorrect username or password."
    )
else:
    print("Nothing found")
mandatory_field = driver.find_element_by_name("login").clear()

#To click forgot link and inserting email id as m.ie
forgot_password = driver.find_element_by_link_text("Forgot password?")
forgot_password.click()
Beispiel #3
0
'''
Created on 17/03/2017

@author: Rachappa
'''
from selenium import webdriver
import time
from lib2to3.tests.support import driver
if __name__ == '__main__':
    driver=webdriver.Firefox()
    driver.get("https://seller.flipkart.com/?utm_source=flipkart&utm_medium=website&utm_campaign=sellbutton")
    
    driver.find_element_by_id("useremail").send_keys("*****@*****.**")
    driver.find_element_by_id("userphone").send_keys("7353249488")
    driver.find_element_by_id("edit-submit--2").click()
    driver.find_element_by_link_text("/slp/services").click()
    
Beispiel #4
0
'''
Created on 30/03/2017

@author: Rachappa
'''
from selenium import webdriver
import time
from lib2to3.tests.support import driver
if __name__ == '__main__':
    driver = webdriver.Firefox()
    driver.get("https://twitter.com/signup?lang=en")
    driver.find_element_by_id("full-name").send_keys("rachappa")
    driver.find_element_by_id("email").send_keys("*****@*****.**")
    driver.find_element_by_id("password").send_keys("rach222")
    element = driver.find_element_by_class_name("js-current-language")
    time.sleep(2)
    e1 = element.click()
    time.sleep(2)
    driver.find_element_by_xpath().click()
    driver.find_element_by_id()
    driver.find_element_by_class_name()
    time.sleep(1)
    driver.find_element_by_xpath()
    time.sleep(3)
    driver.find_element_by_xpath()
Beispiel #5
0
#! /usr/bin/env python
#coding=utf-8
import os
import time
import unittest
from selenium import webdriver
from lib2to3.pgen2.driver import Driver
from lib2to3.tests.support import driver

PATH = lambda p: os.path.abspath(os.path.join(os.path.dirname(__file__), p))
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4.4'
desired_caps['deviceName'] = 'hongmiwang'

desired_caps['app'] = PATH(
    'F:\\wanghailongworkspace\\ContactManager2.5.321.apk')
#desired_caps['appPackage'] = 'com.xiangchao.starspace'
#desired_caps['appActivity'] = 'com.xiangchao.starspace.activity.SplashActivity'

#如果设置的是app在电脑上的路径,则不需要配appPackage和appActivity,同理反之

driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)  #启动app

time.sleep(5)  #启动app时,需要一定时间进入引导页,所以必须设置等待时间,不然下面会一直报错定位不到元素

driver.find_element_by_id('com.xiangchao.starspace:id/skip').click()

driver.quit()
Beispiel #6
0
'''
Created on 06-May-2019

@author: racha
'''
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from lib2to3.tests.support import driver
from selenium.webdriver.support.ui import Select
import time

driver = webdriver.Firefox()
driver.get("https://www.redbus.in/bus-tickets/")
driver.maximize_window()
time.sleep(4)
driver.find_element_by_id("txtSource").send_keys("Bangalore (All Locations)")
time.sleep(4)
driver.find_element_by_id("txtDestination").send_keys("Kukatpally, Hyderabad")

datefield = driver.find_element_by_id('txtOnwardCalendar')
datefield.click()
datefield.send_keys("11052019")

time.sleep(5)

datefield = driver.find_element_by_id('txtReturnCalendar')
datefield.click()
datefield.send_keys("12052019")

time.sleep(5)
Beispiel #7
0
desired_caps['deviceName'] = '192.168.28.101:5555'
#使用unicodekeyboard的编码方式来发送字符串
desired_caps['unicodeKeyboard'] = True
#将键盘隐藏
desired_caps['resetKeyboard'] = True
#可以获取toast弹窗消息
desired_caps['automationName'] =  'Uiautomator2'
#APP的绝对路径--安装
#desired_caps['app'] = PATH('D:\android-sdk-windows\platform-tools\tianbaodai_v1.0_baidu.apk')
#参数
desired_caps['appPackage'] = "com.ibeesaas.tianbaodai"
desired_caps['appActivity'] = "com.ibeesaas.tianbaodai.view.MainActivity"
#启动APP
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps)

'''
 is toast exist, return True or False
   :Agrs:
    - driver - 传driver
    - text   - 页面上看到的文本内容
    - timeout - 最大超时时间,默认30s
    - poll_frequency  - 间隔查询时间,默认0.5s查询一次
   :Usage:
    is_toast_exist(driver, "看到的内容")
   

def is_toast_exist(driver,text,timeout=30,poll_frequency=0.5):
   try:
     toast_loc = ("xpath", ".//*[contains(@text,'%s')]"%text)
     WebDriverWait(driver, timeout, poll_frequency).until(EC.presence_of_element_located(toast_loc))
     return True
Beispiel #8
0
'''
Created on 06-May-2019

@author: racha
'''

from selenium import webdriver
import time
from lib2to3.tests.support import driver
from selenium.webdriver.support.ui import Select

driver = webdriver.Firefox()
driver.get("https://www.redbus.in/bus-tickets/")
time.sleep(5)
# Maximize page
driver.maximize_window()
time.sleep(3)
# Scroll down page
driver.execute_script("window.scrollTo(0, 1500);")
time.sleep(5)
#Drop down option selection
select = Select(driver.find_element_by_id('sourceDrop'))
select.select_by_visible_text('Chennai')
select.select_by_value(2)
#time.sleep(5)
#driver.find_element_by_xpath("//*[@id='time-btn5']").click()
Beispiel #9
0
#incoding=gbk
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from json.decoder import BACKSLASH
from lib2to3.tests.support import driver

driver=webdriver.Chrome()
driver.get('http://www.baidu.com')

driver.find_element_by_id('kw').send_keys('seleniumm')
time.sleep(1)

driver.find_element_by_id('kw').send_keys(Keys.BACK_SPACE)
time.sleep(1)
driver.find_element_by_id('kw').send_keys(Keys.SPACE)
driver.find_element_by_id('kw').send_keys('½Ì³Ì')
time.sleep(1)

driver.find_element_by_id('kw').send_keys(Keys.CONTROL,'a')
time.sleep(1)

driver.find_element_by_id('kw').send_keys(Keys.CONTROL,'x')
time.sleep(1)
driver.find_element_by_id('kw').send_keys(Keys.CONTROL,'v')
time.sleep(1)
driver.find_element_by_id('su').send_keys(Keys.ENTER)
time.sleep(1)
driver.quit()

                            
Beispiel #10
0
    driver.get(
        "http://www.firstnaukri.com/freshersmnj/mynaukri.php/ForgotPassword/showForgotPassword"
    )
    time.sleep(1)
    #driver.find_element_by_xpath("//img[@src='http://static.naukimg.com/sfnr/images/fn_logo.gif']").click()
    #time.sleep(1)
    #driver.find_element_by_xpath("//div[@id='spanid_qf']").click()
    #time.sleep(3)
    #driver.find_element_by_xpath("//a[text()='MCA']").click()
    #time.sleep(3)
    #element=driver.find_element_by_name("ql")
    #element.clear()
    #element.send_keys("bangalore")
    #time.sleep(3)
    #element=driver.find_element_by_name("qp")
    #element.clear()
    #element.send_keys("python")
    #driver.find_element_by_xpath("//input[@value='Search']").click()
    #time.sleep(3)
    #driver.find_element_by_xpath("//span[@class='loc'] ").click()
    #time.sleep(3)
    driver.find_element_by_id("btnsubmit").click()
    driver.find_element_by_xpath("//a[@class='cancel']").click()
    time.sleep(3)
    driver.find_element_by_xpath("//a[@onclick='flogin();']").click()
    time.sleep(3)
    driver.find_element_by_xpath("//label[@id='loginbutton']").click()
    frame = driver.find_element_by_xpath(
        '//frame/button[@class="fn_logBtn fn_mR5 fn_fL"]')
    driver.switch_to.frame(frame)