-done"; # } # } # #SetTimeout (f, +); # })(); # """) # #For I in xrange (+): #if "Scroll-done" in Browser.title: # Break #Time.sleep (Ten) #just intercept the QR code on the right side of the programming Web site, and you can execute a section of jquery: Siblings (). Remove () Remove sibling elementsBrowser.execute_script ("""$ (' #main '). Siblings (). Remove (); $ (' #aside__wrapper '). Siblings (). Remove (); $ ('. Ui
Finally, I stepped into the path of learning automation. Originally is to exclude the code, but did not think really seriously to learn the time, found that he is interesting, finished homework feel good to have a sense of accomplishment. Learning process, also encountered a lot of problems, try to find a solution to the problem, can not find a solution, there are colleagues to ask. This kind of learning opportunity, very rare AH.Have now learned the
input box, the data is passed into Send_keys (Hzy). This is called by loop until all the contents of the file are read.Second, login parameterizationNow according to the above ideas, the Automation script user, the name of the password parameterized, through the Python document we found that Python read the file: The entire file read, read-line, fixed byte read.Did not find a good way to read two data at a time.Create two files, each of which holds t
ObjectiveSome small partners learned selenium alert, no matter what pop-up box to use alert, this is not working, see the Popup box, first to determine whether it is alert, is to use, not the words certainly can not be used.
Some pop-up boxes are div layers, which are like normal positioning methods
Some pop-up boxes are nested IFRAME layers, which can be switched by IFRAME
Some pop-up boxes compare pits, which are embedded in a windo
buttonDRIVER.FIND_ELEMENT_BY_ID ("download-btn"). Click () Four, chrome configuration#Coding:utf-8 fromSeleniumImportWebdriverprofile=Webdriver. Chromeoptions () prefs= {'profile.default_content_settings.popups': 0,#set to 0 to suppress pop-up windows 'download.default_directory':'d:\\'}#Specify the download pathProfile.add_experimental_option ('prefs', Prefs)#Executable_path This is the path to chromedriver. If the environment variable is set, this parameter can be omittedChromedriver_
First install the environment you can refer to this article https://www.zhihu.com/question/30496889I use Chrome to browse, download Webdriver's address is http://chromedriver.storage.googleapis.com/index.html,Click to download the historical version of Chrome: https://www.chromedownloads.net/Note that the downloaded version must correspond to its own version of Chrome, or the error will be as follows: version support for Chromedriver can be viewed from http://npm.taobao.org/mirrors/chromedriver/
the same, first first step to learn to use the tool to view the XPath of an element3. installation steps, copy the corresponding XPath address in the friepath plugin 10. Element positioning: Find_element_by_css_name ()1.css is another syntax that is more concise than XPath, but not very well understood. Here first learn how to use tools to view, follow-up tutorials and further in-depth explanation2. Open the Firepath plugin to select CSS3. position to the rear as shown in red areaFinal Summary
) to locate the child element, which is the XPath The wording is very different, in fact, very good understanding, direct translation came to the first few childrenSix, CSS: Logical Operations1.css can also implement a logical operation, matching two properties, which is not the same as XPath, no need to write the and keywordSeven, CSS: Fuzzy Matching1.css Fuzzy matching contains (' xxx '), although the Internet with a variety of data display can be used, but the small part of the test in perso
.6. Test Execution Report and log is HTML format, easy to read.The 7.Robot framework is not an automated test tool like QTP. It is an automated testing framework, or an automated test platform.8. Provides a listening interface for test execution events, and can customize scripts in the interface. For example, a script in the "Start_test" interface will be executed before a use case executes, and the script in the "End_test" interface will be executed when the execution of the use case is complet
This is a method that can be called directly in mainprivate static void ie () {Webdriver Driver;IE started successfully, files is to start IE driverSystem.setproperty ("Webdriver.ie.driver", "Files/iedriverserver.exe");Code off IE some configurationDesiredcapabilities DC = Desiredcapabilities.internetexplorer ();Dc.setcapability (Internetexplorerdriver.introduce_flakiness_by_ignoring_security_domains, true);Dc.setcapability ("Ignoreprotectedmodesettings", true);Load shutdown configuration into I
As shown, a progress bar control may appear on some Web pages, and the control's structure code is first clarified when it is processed, such as:The control here consists of three parts: a progress bar, a slider, and an input box. The input box has been introduced before, no longer tellsThe progress bar can get the current value through the Title propertySpecific operation can be achieved through the actionchains in the Move_by_offset to achieve the movement of the slider, the specific code is a
1.xptah can be positioned by the attributes of the element's ID, name, classDriver.find_element_by_xpath ("//input[@id = ' kw1 ']")Driver.find_element_by_xpath ("//*[@name = ' wd ']")Driver. Find_element_by_xpath ("//*[@class = ' s_ipt ']") 2. If an element ID, name, and class attribute are not available, you can also navigate to theDriver.find_element_by_xpath ("//*[@autocomplete = ' off ']")Driver.find_element_by_xpath("//input[@type = ' text ']")3. Logical operation4.xpath IndexDriver.find_el
1. Wait methodThe sleep method of the time module is inefficientImplicitly_wait () Set Webdriver wait time, wait, wait, all elements are loaded.Webdriverwait wait for the condition to be met or timeout after exiting the display retry waitFrom Selenium.webdriver.support.ui import webdriverwaitExample 1:Browser.implicitly_wait (5)browser.find_element_by_id (' KW1 ')5 Seconds to view no KW1 elements and then an error.Example 2:From Selenium.webdriver.support.ui import webdriverwaitdef get_ele_times
The previous article is the positioning of elements, then the purpose of positioning elements is to manipulate elements, such as writing text, click Buttons, drag and so on operations(1) Simple element operationSimple element manipulationfind_element_by_id ("kw"). Clear () #文本框清空 find_element_by_id ("kw"). Send_keys ("selenium") #文本框输入find_element_by_id ("button "). Click () #点击按钮操作(2) Common oper
= ' 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,
Encounter problems1. When executing the jquery script, error:
Selenium.common.exceptions.WebDriverException:Message:unknown Error: $ is not defined
2. Some of the following methods have been tried in the future without effect:
Sleep time is a bit longer, so the page is loaded to completion
A different click Method:
$ ('. Btn '). Trigger (' click ')$ ('. btn '). EQ (0). Trigger (' click ')
JS Solution1. I later communicated with the great God who understood jquery, bec
"); Chromeoptions.addarguments (" window-size=1280,900 ");Run Chromedriver in 0LINUX/MAC environment need to force set it as executable fileFilefile=newfile ("Chromedriver path"); File.setexecutable (true);-GeckodriverProfilesiniprofile=newprofilesini (); Firefoxprofileffprofile=profile.getprofile ("Default"); Capabilities.setcapability (Firefoxdriver.profile, Ffprofile); Setting firefoxoptionsfirefoxoptions=newfirefoxoptions (capabilities) for certificate authentication, firefoxoptions.setcapab
1. The entire framework directory is as follows:Constant: Store some constants, such as the URL of the test, and the elements that some PR methods need to use;Errorpicture: Used to store errors during automatic operation;Framework: Classes and methods for storing some basic;Pages: a page class for storing pageobject;Publicmethod: Used to store some PR methods;Question: Used to store some problems encountered during the development process, and where the framework needs to be optimized now;Report
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.