Appium+python the pit during use

Source: Internet
Author: User

Several issues in the process of recording appium use:

1. Selenium.common.exceptions.sessionnotcreatedexception:message:a new session could not be created when re-running. (Original error:requested A new session but one is in progress)
The reason is that there is no kill process in the code
View Appium process: Netstat-aon|findstr 4723
Forced kill process: c:\pycharmproject\buddytest1>taskkill/f/pid 7756


2, the positioning element will be abnormal, the program will error stop running, sometimes want to skip the exception to perform the next test case, to be processed
Nosuchelementexception Exception:
1) Positioning error
2) Element in wait
Processing:
From selenium.common.exceptions import nosuchelementexception
Try

Except
Print
Else

Example:
#实名认证
def certificationbtn (self):
Try
Self.by_text ("real name Authentication")
Except Nosuchelementexception as msg:
Print "Find real-name authentication element exception"%msg
Else
Return Self.by_text ("real name Authentication")

3, Error: Urlerror: <urlopen error [Errno 10061] >
Cause: The agent may be set
4. Wait for activity to appear
Reason: Click to jump to wait for an element to appear before you can click, or error, generally use time.sleep (seconds), but wait for how long uncertain. You can use the Wait activity function.
Use:
# Wait for the main page activity to appear, within 30 seconds

Driver.wait_activity (". Base.ui.MainActivity", 30)
5, appears ioerror: [Errno] Invalid mode (' RB ') or filename: ' \xe2\x80\xaad:\\apitestcase.xlsx ' ERROR
Method:
Method 1: Path uppercase D disk changed to lowercase, unsuccessful
Method 2:
Encoding format issues
Import Sys
Reload (SYS)
Sys.setdefaultencoding (' UTF8 ')

Appium+python the pit during use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.