This section focuses on:
Driver.get_cookies () Get cookie information
Add_cookie (COOKIE_DICT) Adds session information to cookies
Delete_cookie (name) deletes a specific (partial) cookie
Delete_all_cookies () Delete all Cookies
It's fun to manipulate cookies through webdriver, and sometimes we need to know if a cookie is in the browser, Webdriver can help us read, add, and delete cookies.
Print cooki
Original URL:
Http://www.cnblogs.com/fnng/p/3183777.html
This section focuses on: positioning of Simple objects
-----The core of automated testing
Object positioning should be the core of automated testing, in order to manipulate an object, you should first identify the object. An object is a person, he will have a variety of characteristics (attributes), such as we can through a person's ID number, name, or he lives in which street, floor, number of people find this person.
Then an object has
-----The core of automated testing
Object positioning should be the core of automated testing, in order to manipulate an object, you should first identify the object. An object is a person, he will have a variety of characteristics (attributes), such as we can through a person's ID number, name, or he lives in which street, floor, number of people find this person.
Then an object has a similar attribute, and we can find this object through this property.
There are several common purposes for
' exceptAssertionerror as E:return 'Logon Failure'if __name__=='__main__': Driver=Webdriver. Chrome () Driver.get ('http://pandarola.pandadata.cn') Driver.maximize_window () ImgElement= driver.find_element_by_id ('codeimg') Authcodetext=Get_auth_code (driver,imgelement) pandarola_login (Driver,'Admin','1', Authcodetext) driver.quit ()Because our system belongs to the internal system, the verification code is relatively simple, so it is easy to iden
= ' login ']"). Click () #使用Xpthon定位登录按钮 #d=driver.switch_to_ Alert () .text #获取点击登录后, Pop-up dialog Contents #driver.switch_to_alert (). Accept () #获取对话框焦点, accepting dialog box Contents # ifuser== ': print (' Enter an empty user name, enter a blank password, Prompt as follows: ') elifpwd== ': print (' Enter the user name%s, enter the password is empty%s, prompt as follows: '% (user,pwd)) #打印输入的用户名和密码 #else: print (' Enter the user name%s, enter the password for%s, prompt as follows: '% (user,
No nonsense, go directly to the topic, this time demonstrates how to start Chrome, and specify the default profileDownload ChromedriverAddress: http://chromedriver.storage.googleapis.com/index.html?path=2.33/Special Note: Look Notes.txt Note the version number must match Ah, if the chromedriver version and your Chrome version does not match it may not start!!!!!Actual combat code(Can run code please follow the public number, then in the public number to reply "Test help Diary" to get, not in thi
The focus of this section
Working with Drop-down boxes
Switch_to_alert ()
Accept ()
Dropdown box is our most common kind of page elements, for the general element, we only need to position once, but the contents of the dropdown box needs to be positioned two times, first navigate to the Drop-down box, and then navigate to the dropdown box in the options.
Drop_down.html
Saving the above code to HTML opens with a browser to see the simplest common drop-down box, with several options for the
Sometimes in order to ensure the stability of the script run, you need to add the wait time in the script. Add hibernation
Import timeTime.sleep (0.3)Implicit wait
Set once, and after the element is not found, it will wait for 30s by default until the element is found. That is, there is a 30s waiting buffer to find the element. Driver.implicitly_wait (30) Explicit wait
Webdriverwait (). until () #10s内每隔500毫秒扫描一次页面变化, locate the UL element with ID dropdown1 webdriverwait (driver, ten). Until (
cookie value
Delete Browser so the cookies
Method: Delete_all_cookies () instance: Driver.delete_all_cookies ()
Delete a specified cookie
method: Delete_cookie (name) instance: Deriver.delete_cookie ("my_cookie")
Add cookies
method: Add_cookie (cookie_dict) instance: Driver.add_cookie ({'name':' Xiaoqiang'# Note that what is needed here is a dictionary
Gets the current window's
Method: Save_screenshot ( ' image storage Path/image name ')
the following code.
Js= "var Q=document.getelementbyid (' id '). scrolltop=10000"
Driver.execute_script (JS)
Note: Since no suitable examples have been found, no validation, from the reference point of view this should be no problem, such as please feedback.
Scene Two
There is a scroll bar everywhere visible, this is easier to find examples, we operate Baidu search results page for example:
#coding =utf-8 from
Selenium import
compatibility-test your application to see if it works well on different browsers and operating systems, test system functions-Create regression tests to verify software functionality and user needs, support automatic recording actions, and automatically generate. NET, Perl, Python , and test scripts in different languages such as Ruby and Java. Selenium is an acceptance testing tool ThoughtWorks specifica
selenium RC provides a dictionary-based API, all of which are open in one class, and the Webdriver API is more object-oriented. In addition, Webdriver only supports Java, while Selenium RC offers a wide range of language support. The technical differences are also obvious: Seleniu
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.