Seven: Appium element list targeting

list Positioning Integrated Case - user registration
test scenarios
1. Go to the registration interface settings avatar
2. Enter the registration information: user name, password, email
3. improve institutions and professional information (colleges and universities: Shanghai - Tongji University Specialty: Economics class - statistics - economic statistics)
4. complete registration

Code implementation
kyb_register.py

from find_element.capability import driver
import random

# Enter the registration interface to select and set avatar 
driver.find_element_by_id ( ' com.tal.kaoyan: the above mentioned id / login_register_text ' ) .click ()

driver.find_element_by_id('com.tal.kaoyan:id/activity_register_userheader').click()

Images = driver.find_elements_by_id ( ' com.tal.kaoyan: ID / item_image ' ) # get all the elements, which element is again designated 

Images [ 10 ] .click ()

driver.find_element_by_id('com.tal.kaoyan:id/save').click()

# Registration information to fill 
username = ' zxw2018 ' + ' FLY ' + STR (the random.randint (1000,9000 ))
 Print ( ' username: S% ' % username)
driver.find_element_by_id('com.tal.kaoyan:id/activity_register_username_edittext').send_keys(username)

password='zxw'+str(random.randint(1000,9000))
print('password: %s' %password)
driver.find_element_by_id('com.tal.kaoyan:id/activity_register_password_edittext').send_keys(password)

email='51zxw'+str(random.randint(1000,9000))+'@163.com'
print('email: %s' %email)
driver.find_element_by_id('com.tal.kaoyan:id/activity_register_email_edittext').send_keys(email)
driver.find_element_by_id('com.tal.kaoyan:id/activity_register_register_btn').click()


# Institutions selected 
driver.find_element_by_id ( ' com.tal.kaoyan: ID / perfectinfomation_edit_school_name ' ) .click ()

# Select Province 
driver.find_elements_by_id ( ' com.tal.kaoyan: ID / more_forum_title ' ) [. 1 ] .click ()
 # select specific institutions - Tongji 
driver.find_elements_by_id ( ' com.tal.kaoyan: ID / university_search_item_name ' ) [. 1 ] .click ()


# Professional choice 

driver.find_element_by_id ( ' com.tal.kaoyan: the above mentioned id / activity_perfectinfomation_major ' ) .click ()
 # select the type of Economics - statistics - Economic statistics 
driver.find_elements_by_id ( ' com.tal.kaoyan: the above mentioned id / major_subject_title ' ) [. 1 ] .click ()
driver.find_elements_by_id('com.tal.kaoyan:id/major_group_title')[2].click()
driver.find_elements_by_id('com.tal.kaoyan:id/major_search_item_name')[1].click()


# Click "enter postgraduate help" button 

driver.find_element_by_id ( ' com.tal.kaoyan: the above mentioned id / activity_perfectinfomation_goBtn ' ) .click ()

Note: Before running the noRest to remember: Registration residual information so as not to interfere with the previous desired_caps [ 'noReset'] = 'False'.

& Solution error
element positioning error

selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.

[Solution] to check whether the value of the element id wrong.

References https://blog.csdn.net/u011541946/article/details/77922304

 

Guess you like

Origin www.cnblogs.com/zhenyu1/p/11943007.html