Using Eclipse to write Webdriver drive Selenium test problem processing method
Problem: Org.openqa.selenium.firefox.NotConnectedException:Unable to connect to host 127.0.0.1 in Port 7055 after 45000 Ms. Fir Efox Console output:
Changes
Description: The version of Firefox is not consistent with the version
As a result, the problem can be handled as long as the two versions correspond.
The versio
First, the code implementationSecond, the realization principlePlease refer to the comments sectionThird, the problems encounteredStart in the process of running, always prompt null pointer exceptionReason: The @beforemehtod was written @beforeThe former belongs to the tsetng, the latter belonging to JUnitIv. SummaryMain methods: Getwindowhandle (), Dr.switchto (). window (ParentID);The method through which the caption is GetTitle (), through the content of the method is Getpagesource ()
Linktext is the link text, we can find the element by LinktextFirst, the problem scenarioIn HTML the,As an example of a red box, an HREF represents a jump address after the link has been clicked, selenium to find the element by text informationSecond, the Code implementationThree, the realization principle1, first open the corresponding URL2. Navigate to the link by text message3. Click the link to open the CSDN blog link in the new interfaceIv. Matte
Error message:Webdriverexception:message: Unexpected error launching Internet Explorer. Browser zoom level is set to 109%. It should BES set to 100% ??the browser security setting should be 100%??Workaround:"Open Regedit and navigate to HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\zoom. In the right-hand pane are a listing for Zoomfactor. Double-click on it and click the button next to Decimal. Change the value from 110000 to 100000, click OK, and Exit Regedit. Now every time you open
Refer to Http://www.cnblogs.com/tobecrazy/p/3599568.htmlWebdriver, you need to introduce:ImportJava.io.File;ImportJava.io.IOException;ImportOrg.apache.commons.io.FileUtils;ImportOrg.openqa.selenium.OutputType;Import Org.openqa.selenium.TakesScreenshot;Methodpublic static void Snapshot (Takesscreenshot drivername, String filename){This method would take the screen shot, require-parameters, one is driver name, and another is file nameString Currentpath = System.getproperty ("User.dir"); Get Curren
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 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
Public voiduploadfile (String path) {//File File = new file ("C:\\jacob-1.18-m2-x64.dll"); //System.setproperty (Libraryloader.jacob_dll_path, File.getabsolutepath ());//Add the DLL to the system variable. or throw it under the System32.AUTOITX x=NewAutoitx (); Locale Locale=Locale.getdefault (); String title= "Open"; String BrowserType=TestCase.DriverManager.browserType; if(Browsertype.equals ("CHROME")) { if(Locale.getdisplaylanguage (). Equals ("Chinese")) title = "Open"; if(X.winw
In Windows cmd execute "python test.py", no problem, the browser open normally, the test results are normal.Problem:But if it is in Jenkins, choose "Execute Windows Batch command", configure "Python test.py" run test, this time there will be a problem, Chrome browser will not open, but there are processes in the background, Test.py runs in the background, but runs test.py in the background and the browser does not open.For such a problem, the workaround:1) Using administrator permissions, execut
of Selenium
2004 at ThoughtWorks, a company called Jason Huggins to reduce manual testing, he wrote a set of JavaScript libraries that can interact with pages and repeat tests on different browsers.
This set of libraries later became selenium Core. Provides a solid core foundation for the Selenium Remote control (RC) and s
First, Test System: Python + Selenium + pycharm + Jenkins/dockerEnvironment Construction:1. Install python 3.4/3.5 2/3.6/3.72. Configure Environment variables3.pip Install selenium== version number 3.3 (frame with the latest in mature language)4. Install editor Pycharm, Project path cannot contain Chinese, name is meaningful, Python version is selected correctly5. browser Firefox version can go to https://w
Firefox. However, its recording is quick and easy to use! With the Code Conversion Function, you can convert selenium language test cases to C #, Java and other language test cases. I suggest using selenium ide + firebug to write test cases, then convert the test case to another language, and then call selenium RC to run the test case.
(2 ).
interpreter,selenium can be downloaded according to my first blog's practice. PHANTOMJS, you can directly through the link I gave to download. When the two are all installed, you can start data capture formally. Of course, the example is my blog ~First on the sample code!#-*-coding:utf-8-*-# fromSeleniumImportWebdriverdefcrawling_webdriver ():#get local session of PHANTOMJSDriver = Webdriver. PHANTOMJS (ex
a seleniumWhat is it? quoted Baidu Encyclopedia introduction Selenium A passage:" Selenium is a tool for WEB application testing. the Selenium test runs directly in the browser, just as the real user is doing. Supported browsers include IE(7, 8, 9, ten, one),Mozilla Firefox,Safari,Google Chrome,Opera and so on. The mai
The Selenium IDE is a plugin in the Firefox browser that records your actions on Firefox and replays its operations. It's easy to use, but I don't think it's very useful.
Reading Table of Contents
Selenium IDE Introduction
The role of the Selenium IDE
Selenium
-server-standalone-2.22.0.jar-port 4001-role Node-hub http://127.0.0.1:4000/grid/register#显然, you can start multiple node:Java-jar selenium-server-standalone-2.22.0.jar-port 4002-role Node-hub http://127.0.0.1:4000/grid/registerWebdriverWebdriver provides an advanced technology to locate Web page elements. In fact, Webdriver is based on the selenium of an automat
Selenium RC is the use of programming language script, through the Selenium RC server as a proxy server to access the application to achieve the purpose of the test. Since Selenium RC no longer needs to be dependent on Firefox, it can be tested on a number of other browsers, And that's one of the more important things we do with web testing (solving problems that
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.