夏休み前半に勉強したテスト自動化の内容をまとめます
- 使用したUdemy教材
- Interface in Java
- Stringとは
- methodの違い
- Print a string in the reverse sort
- Selenium Web Driver Locators
- When would you see the element "intercept"?
- Implicit wait
- Identify the elements with the help of partial text, by using the star
使用したUdemy教材
Interface in Java
-Interface is a group of related method with empty body.
-Interface enforces contract to class to follow.
- WebDriver driver = new ChromeDriver();
Web driver is an interface that Chrome driver is implementing. And we want to refer only web driver-implemented methods.
- ChromeDriver driver = new ChromeDriver();
This code might not work in other browsers if this driver is accessing the personal chrome driver class method.
Stringとは
×文字列
○文字列を表す参照型の型(object that represents a sequence of characters.)
Stringの定義
(1)String 変数名 =new String("A");
文字列が同じでもnewを付ければいくつでも作れる
(2)String 変数名="A";
文字列が同じであれば変数は一つ。メモリ領域を有効に使える。
メモリについてはここがわかりやすかった↓
java:参照型変数やメモリの理解に苦しむ若手Java技術者に向けて – サイゼントの技術ブログ
methodの違い
-driver.close:close current window
-driver.quit: quit all the windows which opened by automation
Print a string in the reverse sort
String[] name = {"A", B", "C"};
for(int i =0; i<name.length;i++)
{
System.out.println(name[i]);
}
As is: for (int = 0; i<s.length(); i++)
Reverse: for (int i = s.length()-1; i>=0; i--)
Selenium Web Driver Locators
<input type="text" placeholder="Username" id= “inputUsername” value=" ">
Input -> tag name
Red-> attribute
Green-> attribute associated value.
CSS selector
CSSの場合 Parenttagname childtagname body header(スペース入れる)
When would you see the element "intercept"?
When the app is in changing state from one view to another, you might run into that interception error.
At that time, you must wait until that view get stable.
Implicit wait
waiting for objects to show on the page.something to show
something to get in a stable state.
★implicit wait vs thread.sleep
Identify the elements with the help of partial text, by using the star
input[type*='pass' ]
${input[type*="pass"]}