automation testing -k8凯发
-
java
-
starting with java language and oop concept
-
overview abount java
- http://www.tutorialspoint.com/java/index.htm
- http://android.vn/threads/mien-phi-khoa-hoc-lap-trinh-java.25642/
-
installing
- \\192.168.176.122\apps\developer\development\eclipse
- c:\program files\java\jdk directory:
- right-click on 'my computer' and select 'properties'.
- click on the 'environment variables' button under the 'advanced' tab.
- 'c:\windows\system32', then change your path to read 'c:\windows\system32;c:\program files\java\jdk\bin
-
basic syntax
-
convention
- classname.java
- classname
- class myfirstclass
- methodname
- public void mymethodname()
- start a program in
public static void main(string args[])
- objects and classes
- contructor
- variable types
- basic operators
-
java strings
-
khởi tạo
- string str1 = new string();
str1 = "chuỗi";
- string str1 = new string ("chuối");
- string str1 = "chuoi";
- java array
- java methods
- create a simple project
- how to create a package
- how to create a class
- how to implement an object
- exception concept
-
practice
- create a java project for calculating 2 integer variables
- create a package, named: pack
- create a class that provide 4 methods: minus, plus, multi, divide. 2 parameters will be passed from contructor of class. with each method, it will pass parameters and calculate result, then print out console
- create a package, named: test
- create a main class to test.
-
from me
-
overvỉew
-
java is
- object oriented
-
class
- class
- interface
- abstract class
-
constructor
- hàm khởi tạo các thuộc tính
-
selenium
-
plan
-
selenium overview
-
introduction
- hướng dẫn bằng tiếng việt
- http://www.tutorialspoint.com/selenium/selenium_webdriver.htm
- http://www.guru99.com/selenium-tutorial.html
- ghi lại hành động trên web và thưc thi kịch bản
-
working with selenium ide
- installing
- firefox
- www.seleniumhq.org/download/
- cài add on selenum ide
- chọn đúng ver firefox và selenium
- selenium ide basics
- recording a test
- https://www.youtube.com/watch?v=ppeqb0t89uy&list=plptco0fa9gr16y11kfmynol80yhvrksrs&index=3
- create scenario
- open url
- record the steps
- verify result
- perform on browser
- running the test
- run on selenium ide of browser
- verifytest message
- selenese
- looking at commands
- waitforelement
- chờ element hiển thị
- deleteallvariablecookie
- xóa biến cookie (sản phẩm giỏ hàng)
- creating commands
- insert comment for steps
- điền tạm vào field sau đó sưa mục values
- diểm đừng add breakpoint
- pause breakpoint at each scenario
- set start point
- chạy thẳng từ point đc set
- step
- chạy từng step
- actions - directly interacts with page elements
- action
- click
- action andwait
- acction dùng khi page đc tải lại từ server
- waitfor...
- dùng khi biến đổi về giao diện với javascipt
- listbox combobox và checkbox
- select
- multiple select
- addselection
- removếlection
- checkbox
- click
- action check <=> uncheck
- check
- always check
- verifycheck
- subtopic 1
- uncheck
- always uncheck
- verifynotcheck
- accessors - "reads" an element property and stores it in a variable
- khai báo biến
- store
- echo - kiểm tra kết quả trả ra ntn
- target =${biến}
- target
- giá trị
- values
- x
- storetext
- khai baó text nằm giữa 2 thẻ html
- //p
- //div
- storevalue
- khai báo giá trị của thẻ có thuộc tính value
- //input
- storeattribute
- khai báo cho các thuộc tính trong thẻ html
- //div@align
- //input@value
- ~ storevalue
- assertions - compares an actual value with an expected one
- verifications
- target =${biến}
- verifytext
- dùng cho đối tượng có chứa text
- verifyvalue
- dùng cho thuộc tính value của thẻ html đối tươngj chứa values
- verifyattribute
- dùng cho các thuộc tính của thẻ html
- verifyelementpresent
- kiểm tra xem tồn tại trong source code hay không
- verifyvisible
- check element ẩn hiện khi expand
- addon screenshot on failed
- using assert and verify
- verifytest message
- verify failed thì vẫn tiếp tục những cái dưới
- dùng để kiểm tra nhưng thứ ko ảnh hưởng đến bước theo
- asset gặp failed dừng lại luôn
- output liên quan đến logic cho những bước dưới
- creating test suites
- creat test case
- save as testsuit
- save as html
- exporting
- file/export testcase as...
- summary
-
practice
- practice with selenium ide
- http://newtours.demoaut.com/
- go to url
- verify the title of page
- verify the element present
- verify link texts are correct
- verify text is correct
- input user name
- input password
- click to sign in
- verify the title of page appeared
- assert the sign-on link present
- review the exercise of trainee
- se_prac01.html
-
working with selenium webdriver
-
introduction
- http://www.vntesters.com/gioi-thieu-selenium-webdriver/
-
what is webdriver?
- webdriver is a web automation framework that allows you to execute your tests against different browsers,
- cho phép chúng ta sử dụng các ngôn ngữ lập trình để thiết kế test case.
- java
- .net
- php
- python
- perl
- ruby
- ưu điểm
- faster than selenium rc because of its simpler architecture.
- làm việc ở mức os
- direct talks to the browser while selenium rc needs rc server
- api is concise than selenium rc's
- xác định đôi tượng trc rồi mới đến hành động
- support htmlunit
- nhanh vì không lòa element
- limitations
- cannot readily support new browsers, but selenium rc can.
- no a built-in command for automatic generation of test results.
-
setting up java, eclipse, junit
- eclipse
- setting up webdriver
- install java
- install eclipse ide
- download the selenium java client driver
- project_properties/java build path_libraries/add external jars_add jar files in/out the "libs" folder
-
other browsers
- each other browser has its own driver server
-
a simple script
- importing packages
- import org.openqa.selenium.webdriver;
- import org.openqa.selenium.firefox.firefoxdriver;
- instantiation of objects/variables
- webdriver driver = new firefoxdriver();
- string baseurl = "http://newtours.demoaut.com";
- string expectedtitle = "welcome: mercury tours";
- string actualtitle = "";
- launch firefox and direct it to the base url
- driver.get(baseurl);
- get the actual value of the title
- actualtitle = driver.gettitle();
- compare the actual title of the page witht the expected one and print
* the result as "passed" or "failed"
- if (actualtitle.contentequals(expectedtitle)){
- system.out.println("test passed!");
- } else {
- system.out.println("test failed");
- }
- close firefox
- driver.close();
- exit the program explicitly
- system.exit(0);
-
common command
- get commands
- get()
- gettitle()
- getpagesource()
- getcurrent
- gettext()
- navigate commands
- navigate().to()
- navigate().refresh()
- navigate().back()
- navigate().forward()
- closing and quitting browser windows
- close()
- quit()
- switching between frames
- switchto().frame("classframe")
-
finding elements
- web element identification techniques
- locate web elements
- by
- id
- id attribute of a html tag
- target: id=id_of_the_element
- driver.findelement(by.id())
- name
- id attribute of a html tag
- target: name=name_of_the_element
- value=value_of_filter
- driver.findelement(by.name())
- link text
- target: link=link_text
- ex: link=about
- driver.findelement(by.linktext())
- driver.findelement(by.partiallinktext())
- css selector
- tag and id
- css=tag#id
- css=input#email
- tag & class
- css=tag.class
- css=div.wrapper
- only first element in source code is recognized
- tag & attribute
- css=tag[attribute=value]
- css=input[name=lastname]
- only first element in source code is recognized
- tag, class & attribute
- css=tag.class[attribute=value]
- css=input.inputtext[tabindex=2]
- inner text
- css=tag:contains("inner_text")
- css=font:contains("passwords:")
- inditify label on webpage
- driver.findelement(by.cssselector())
- driver.findelement(by.tagname())
- driver.findelement(by.classname())
- xpath
- driver.findelement(by.xpath())
- using firebug or firepath
- //html/body/div/div[2]/div[2]/div[1]/form/div[1
- how to locate dynamic elements by xpath
- tìm vị trí tương đương
- xpath=//input[@id='f1_google']
- find a paragraph element
- xpath=//p[contains(text(),'aaaa']
- xpath=//p[starts-with(text(),'aaa')]
- xpath=//p[ends-with(text(),'aaa')]
- dom (document object model)
- getelementbyid
- target: document.getelementbyid("id_of_the_elements")
- document.getelementbyid("input")
- getelementsbyname
- target: document.getelementbyname("name")[index]
- document.getelementbyname("servclass")[1]
- dom:name
- document.forms["name_of_the_form"].elements["name_of_the_element"]
- document.forms["home"].elements["username"]
- dom:index
- document.forms[index_of_form].elements[index_of_element]
- practice
- practice with locating web elements
- review the exercise of trainee
- page elements
- a more complex script
- assert and verify
-
waits
- implicit wait
- explicit waits
- import these two packages
- import org.openqa.selenium.support.ui.expectedconditions;
- import org.openqa.selenium.support.ui.webdriverwait;
- declare a webdriverwait variable
- mywaitvar.until(expectedconditions.visibilityofelementlocated(by.id("username")));
- driver.findelement(by.id("username")).sendkeys("tutorial");
-
how to work with excel file (reading and writing)
- reading form file
- import poi
- create workbook
- create sheet
- cell
- write to file
-
practice
- practice with selenium webdriver
- write a test script
- write a script using reading/writing from excel file
- review the exercise of trainee
-
hybrid framework (basic)
- introduction
- setting up civica framework
- how to create a test case
- run the test suite
- reporting
- practice with hybrid framework (basic)
- review the exercise of trainee
-
hybrid framework (advanced)
- how to create new keyword
- how to run with multibrowser
- practice with hybrid framework (advanced)
- review the exercise of trainee
-
practice
- go to url: http://newtours.demoaut.com/
- verify the title of page
- verify the element present