Tips and Tricks
Using Drag and Drop
It may not be immediately obvious, but if you're using a browser that supports it , you can use Action classes and then it's easy to do drag and drop:
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(someElement)
.moveToElement(otherElement)
.release(otherElement)
.build();
dragAndDrop.perform();
Currently, only theFirefoxDriversupports this, but you
should also expect support for theInternetExplorerDrivertoo.
Changing the user agent
This is easy with theFirefoxDriver:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("general.useragent.override", "some UA string");
WebDriver driver = new FirefoxDriver(profile);
Tweaking an existing Firefox profile
Suppose that you wanted to modify the user agent string (as above), but you've got a tricked out Firefox profile that contains dozens of useful extensions. There are two ways to obtain this profile. Assuming that
the profile has been created using Firefox's profile manager ("firefox -ProfileManager"):
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("WebDriver");
profile.setPreferences("foo.bar", 23);
WebDriver driver = new FirefoxDriver(profile);
Alternatively, if the profile isn't already registered with Firefox:
File profileDir = new File("path/to/top/level/of/profile");
FirefoxProfile profile = new FirefoxProfile(profileDir);
profile.setPreferences(extraPrefs);
WebDriver driver = new FirefoxDriver(profile);
Enabling features that are disabled by default in Firefox
Native events is such a feature: It is disabled by default for Firefox on Linux as it may cause tests which open many windows in parallel to be unreliable. However, native events work quite well otherwise and are
essential for some of the new actions of the Advanced User Interaction. To enable them:
FirefoxProfile profile = new FirefoxProfile();
profile.setEnableNativeEvents(true);
WebDriver driver = new FirefoxDriver(profile);
How to set language in profile
profile.setPreference( "intl.accept_languages", "no,en-us,en" );
How to find profile keys
Look inprefs.jsof your Firefox profile.
How to find Firefox profile
Goto (url) about:support or FireFox Help menu / Troubleshooting information
相关推荐
Tips and Tricks for Using Microsoft Office SharePoint Portal Server 2003.pdf
PDF Can be Pretty Darn Fancy: Tips and Tricks for the ODS PDF Destination ODS PDF输出的要领.pdf一个经典的SAS Macro 教程PPT1
《深入学习mongodb》英文原版,无水印,非常值得学习。
50 Tips and Tricks for MongoDB Developers
[Kristina_Chodorow]50 Tips and Tricks for MongoDB。MongoDB数据库设计实现优化安全技巧
50 Tips and Tricks for MongoDB Developers中文版
深入学习MongoDB:Scaling MongoDB && 50 Tips and Tricks for MongoDB Developers深入学习MongoDB中文版Scaling MongoDB英文版50 Tips and Tricks for MongoDB Developers英文版高清完整目录3本打包合集
d3 tips and tricks version 4 (javascript d3.js, front-end )
Networkers2009:BRKUCT-3015 - Advanced Tips and Tricks for Self-Service Application Development using Cisco Unified Customer Voice Portal Call Studio
features tips and tricks that an experienced shader programmer will benefit from. As with Direct3D ShaderX, Javier Izquierdo Villagrán (nurbs1@jazzfree.com) prepared the drafts for the ...
【英文参考资料】-AUTOSAR学习资料无人驾驶-Tips and tricks for the use of CAPL
wxPython Grid Tips and Tricks
提供了适用于实际生活中的秘诀和方法(tips and tools),运用这些方法能使你的大脑能够超常工作,让你成为更好的思想者。在当今快速发展的信息经济时代,管理你的生活需要开发你的大脑的潜能。《心理和脑与生活:训练...
From taming the Ribbon bar to testing and tables, creating custom functions, and overcoming "impossible" charts, mixing nesting limits, and more, 101 Excel 2013 Tips, Tricks, & Timesavers will save ...
Visual Studio .NET Tips and Tricks.pdf
计算机图形学 着色器 顶点着色器 像素着色器 DirectX 3D
Some tips and tricks about Windows Ultimate.