CodePudding user response:
I just learn the selenium is small white, I have a stupid way to handle it, is the dynamic id number starting from 1 cycle, + 1 at a time, until id exists and is what I want, click again, the code is as follows (method is very stupid, your advice),Def isElementExist1 (count, xpath, data) :
If the find_element_by_xpath (xpath). The text==data:
The find_element_by_xpath (xpath). Click ()
The else:
Addcount1 (count, xpath, data)
Def addcount1 (count, xpath, data) :
If the count & lt;=20:
The count=count + 1
Xpath='//* [@ id="_easyui_combobox_i37_' + STR (count) + '"]'
IsElementExist1 (count, xpath, data)
Last fall under way:
Data="https://bbs.csdn.net/topics/xxx" # you want to click on the text value of the
Xpath='//* [@ id="_easyui_combobox_i37_' + STR (count) + '"]' # xpath
IsElementExist1 (count, xpath, data)
CodePudding user response:
To suggest other ways to getCodePudding user response:
Through the XPath access to elementsCodePudding user response:
Dynamic ID generation depends on the front end using the framework, and now that is dynamic, you can't use ID positioning elements, suggest change a methodCodePudding user response:
Through the XPath location, format://* [@]CodePudding user response:
This dynamic, suggest you add a WebdriverWait waiting, it just comes out, you can catch it the text inside the
# XXXX: the inside of the label content (best manually copy, some text with the blank space, a pit), double click on the copy, should pay attention to this. The location of the text, behind positioning element code
3,, alert_title=WebDriverWait (web) until (lambda x: web find_element (By CSS_SELECTOR, 'div. Avator span). The text)
If alert_title=="XXXX" : print (" login successfully!" )
The else: print (" login failed!" )
CodePudding user response:
With xpath works wellCodePudding user response:
Don't use id to locate, other properties can be used to locate elements such as//div [contains (@ class, 'layui) and @ type=' dialog '], and so on, and then by locating the element returns the id valueCodePudding user response:
The verification code? Can let the development set a universal authentication code... It is ok to cancelled after launchCodePudding user response:
Can't change the way to locate, use xpathCodePudding user response:
Take take by absolute pathCodePudding user response:
Should be Numbers will get letters will not change, use starts - with () should be ok