I touched Selenium for the time being, so I wrote a little note. However, I haven't tried all of them, so there are many shortcomings.
A tool for testing websites. By writing a script in advance, it is possible to perform the exact operation on the browser and check whether the element exists in the middle and whether the URL matches the expected value.
For the time being, I heard a story like "Selenium when it comes to website testing", so when I googled it, I was very worried because the article was just old, but around 2012, the 2.x series It seems that the product has been released and can still be used.
For the time being, you can download it from the ** English version ** Selenium site. The Selenium site itself has a Japanese version, but you can download 1.x from the Japanese site. First of all, I was really into it here. No matter how much "please see the official website for the latest version" ...
For the time being, place each file in the following location.
In addition, Python here seems to be useless unless it is Version 2 system (3.x does not work properly because there are incompatible parts in various places). I downloaded it from Python official page, but it includes setuptools and pip (necessary for installing Selenium Client). Since there is no such thing, install it referring to the following site.
The easiest way to use it is to start Selenium IDE and record → play the operation.
Roughly like this, you will have a simple operation code.
After that, select the line you want to test and add a test by entering a command such as "Insert command" in the right-click menu and "assertTitle" in the command. At this time, note that the expected value must be entered in the "Target" field, not the "Value" field (I was addicted to it again).
Another point to note is that if you want to wait until the page transition is completed after clicking, use the clickAndWait
command instead of the click
command, and wait for the screen switching process such as Ajax without screen transition. In that case, you can just check the existence of the element by using the waitForVisible
command or the like.
If you want to output the test cases to a file, select Save Test Cases or Export Test Cases from the File menu. If you choose to save test cases, you will get an HTML file with table tags, one test code per line.
If you choose to export, you can specify the language and save the test code to a file. By default, you can select from 4 languages: python, ruby, c #, java, but if you don't like the code format or want to output in another language, you can add it from "Options> Settings".
The exported test cases can be run using their respective interpreters as usual (provided that the Selenium client module for each language is pre-installed). However, as mentioned above, when using Python, it is necessary to have version 2 series. Please note that the script does not work well with 3 series.
Also, in my environment, I couldn't use the file output by Ruby because of a syntax error. I haven't tried C # etc. because it is troublesome to compile.
Test cases exported with "Remote Control" written after the language name will be processed by starting any browser using Selenium Server, so it is necessary to start Selenium Server in advance. See the following site for how to start Selenium Server.
For the time being, it looks like this. If I find something again, I may add it.
Recommended Posts