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