Learn about keyboard actions in selenium webdriver, we have the largest and most updated keyboard actions in selenium webdriver information on alibabacloud.com
http://www.testclass.net/ Test Tutorial Network, professional Selenium learning website.Knowledge points in this section:Action object:
· Click on Object
· Send_keys analog key input on the object
· Clear clears the contents of the object, if possible
Webelement Other common methods:
· Text gets the literal of the element
· Submit Form
· Get_attribute Getting property values
=================================
' outfox_search_user_id '}, {u ' path ': U '/', U ' domain ': U ' www.youdao.com ', U ' name ': U ' jsessionid ', U ' value ': U ' abcux9zdw0minadihtvcu ', U ' secure ': False}]
Actions on Cookies
The way it printed all the cookie information table, too much too messy, we just want to have the right sex to print the information we want to see the following example
#coding =utf-8 from
Selenium impo
methods on the keyboard, Send_keys () does not have the ability to simulate keyboard input, and can also be used to enter keys on the keyboard, even key combinations, such as the following example:# Simulate keyboard eventsFrom selenium import
coordinate)
Perform ()--all actions in the chain of execution
Release (On_element=none)--Releasing the left mouse button at an element position
Send_keys (*keys_to_send)--the element that sends a key to the current focus
Send_keys_to_element (element, *keys_to_send)--sends a key to the specified element
Next, use the example to specify and demonstrate the use of each method:
3. code example
1. Click action
Sample URL http://sahitest.com/demo/
;"); - - //can be partially matched using the Java String API method -Assert.asserttrue (Messagetext.contains ("Job search"))); -Assert.asserttrue (Messagetext.startswith ("View short rent")); -Assert.asserttrue (Messagetext.endswith (">>")); in - //Close Driver to driver.quit (); + } -}code Example2. Get element attribute valuesThe GetAttribute () of the Webelement class returns the attribute value of the element3. Get CSS property values for an elementThe
element, we call the Webelement "setselected ()" method, and Webdriver throws an exception.
We're going to go to an element, and next, we might want to do something, like typing some characters:
Element.sendkeys ("Sone text");
Of course, we can also simulate keyboard input through the "Keys" class:
Element.sendkeys ("and some", keys.arrow_down);
Remember, the strings we enter into these elements are n
value ' + ' can be alteredThread.Sleep (3000);}Scroll automatically to your webelement:Point Hoveritem =driver.findelement (By.xpath ("Value")). GetLocation ();((Javascriptexecutor) driver). Executescript ("return window.title;");Thread.Sleep (6000);((Javascriptexecutor) driver). Executescript ("Window.scrollby (0," + (Hoveritem.gety ()) + ");Adjust your Page view by making changes right over here (Hoveritem.gety ()-400)(OR)((Javascriptexecutor) driver). Executescript ("Arguments[0].scrollintov
operation based on certain events. For example, a text box that cannot be entered becomes an input state. The custom wait can be implemented on the attributes of the element.In this example, the Expectedcondition class waits to return a Boolean value1 (new webdriverwait (driver). Util (new expectedcondition() { 2 Public Boolean Apply (webdriver d) {3 return d.findelement (by.id ("username")). 4 getattribute ("ReadOnly"). Contains ("true");
Selenium webdriver window switch, sometimes in the automation of the need to open a lot of pages,When you are working on a different page, you need to switch windows, and here's how to switch to the front and back page windows: Packagetest20161206;Importorg.openqa.selenium.By;ImportOrg.openqa.selenium.Keys;ImportOrg.openqa.selenium.WebDriver;Importorg.openqa.selenium.WebElement;ImportOrg.openqa.selenium.chr
Reprinted from http://blog.csdn.net/hcx1234567/article/details/17605533After the arduous work, finally solved the UI TA (test automation) in this puzzle, must be recorded.The premise is: This page that needs to be tested is written by Google's Angularjs. Many of the page effects are implemented with some of the events that Angularjs comes with, in conjunction with CSS hover. The UI TA framework for the test is selenium
Selenium provides many API methods to interact with the page, such as click, keyboard input, turn off Web pages, enter text, and more.Webdriver provides many properties to the browser to operate the browser, commonly usedGet (URL), quit () Maximize_window () Current_urlBack () forward () Current_window_handle and window_handles To open Baidu Home-----Point of registration, to register also registered-----
I hover show other a label") >>> Actionchains (chrome_obj). Move_to_element (Label). Perform () # Simulate user hover "" "Actionchains (chrome_obj) is used to generate simulated user behavior;Perform () Execute storage Behavior "" ">>> Label_bel = Chrome_obj.find_element_by_link_text ("I am a tag, point me page Jump")>>> Label_bel.click () # Simulate user clicksOther mouse actionsLabel.countext_lick () # Right-click Label.double_click () # Double-click Label.drag_and_drop () # drag labe
before.Webdriverwait (DR, 10)Scans 1 page changes every 500 milliseconds in 10 seconds, ending when the specified element appears. Dr does not explain that the handle of the front operation Webdriver.firefox ()Is_displayed ()Whether the element is visible to the userClass Actionchains (Driver)Driver: Performing a user action instance webdriverGenerates the user's behavior. All actions are stored in the actionchains object. behavior that is stored thr
://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriverThere are two webdriver in Firefox. Old, called firefoxdriver (do not download, Firefox comes with), new, called Geckodriver (recommended with this). 2.geckodriver and Firefox version corresponding relationshipSee Https://github.com/mozilla/geckodriver#supported-firefoxen.If using Geckodriver, the official recommended Firefox more than 55, while S
Web page automation testing, the elements on the page positioning and operation is the core. And the operation is the premise of positioning, therefore, the positioning of page elements is the basis for automated testing.
The elements on the page, like people, have various attributes, such as element names, element IDs, element attributes (class attributes, name attributes), and so on. Webdriver is the use of these attributes of elements to locate.
Co
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.