Để chạy được kịch bản Selenium IDE trên trình duyệt Chrome và IE thì mọi người cần follow theo một số steps sau:
- Step 01 – Tải về bản Selenium Server Standalone lưu vào 1 thư mục cố định (Trong demo mình lưu tại ổ C):
- Selenium Server Standalone version 2.53.1: http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
- Step 02 -Tải về bản Chrome Driver và IE Driver lưu vào 1 thư mục cố định (Lưu ý là lưu cùng thư mục với Selenium Server Standalone – ổ C)
- Chrome Driver version 2.23: http://chromedriver.storage.googleapis.com/2.23/chromedriver_win32.zip
- IE Driver version 2.53.1: http://selenium-release.storage.googleapis.com/2.53/IEDriverServer_Win32_2.53.1.zip
- Sau khi tải về xả nén ra 2 file (chromedriver.exe và IEDriverServer.exe) nhé, mục đích của 2 file này để khởi tạo 2 trình duyệt Chrome và IE lên.
- Step 03 – Bật Selenium Server Standalone lên và khởi tạo cùng lúc driver của trình duyệt:
- Tại ổ C, nhấn đồng thời phím Shift + chuột phải và chọn <Open command window here>
- Paste đoạn code sau vào command line:
- Cho Chrome: java -jar selenium-server-standalone-2.53.1.jar -Dwebdriver.chrome.driver=chromedriver.exe
- Cho IE: java -jar selenium-server-standalone-2.53.1.jar -Dwebdriver.ie.driver=IEDriverServer.exe
- Sau khi bật thành công nó sẽ có giao diện như sau:
Chú ý: Như trong hình tại step 2 Selenium Server up và running thì mới thành công nhé.
- Step 04 – Config trong Selenium IDE:
- Option > WebDriver > Check vào checkbox: Enable WebDriver Playback > Truyền vào browser thích hợp (chrome, internet explorer)
- Step 05 – Chạy testcase như thông thường (Play current testcase)
- Sau khi click run testcase, Selenium Server sẽ tạo mới 1 session và bật trình duyệt chrome lên để thực thi testcase
Tương tự từ Step 03 cho trình duyệt IE nhé.
Lưu ý:
– Để cho phép run lại testcase trên trình duyệt Firefox thì tại Step 04 cần click vào button Reset Option trong hình (nằm dưới cùng ở giữa) để đưa config browser về mặc định.
– Các step liên quan đến vòng lặp hoặc sử dụng các chức năng liên quan đến extension (Report/ Flow Control/ Screenshot/…) sẽ không chạy được trên Chrome/ IE.
Good luck!
Chào anh,
Em đang làm 1 dự án test chủ yếu trên IE (IE version mới nhất). Theo bài viết này của anh em đã down về và thực hiện viết đoạn lệnh như anh đưa nhưng khi nhấn Enter thì nó báo lỗi. Em đã thử lại rất nhiều lần nhưng vẫn fail. Các bước chạy trên command line đều giống hình anh đưa nhưng đến bước cuối thay vì nó báo Selenium Server is run up… thì bên em lại báo lỗi như sau:
WARN – Failed to Start: SocketListener 0@0.0.0.0:4444
Ngoài ra trước câu WARN này thì em cũng không thấy câu lệnh Remote như trong hình anh đưa.
Mong anh có thể giải đáp dùm em về lỗi này ạ.
LikeLike
Em đã tìm ra nguyên nhân lỗi và đã tìm được cách fix
LikeLike
Good nha (y)
LikeLike
Chào anh!
Hiện em đang tìm hiểu về selenium IDE. Em đã thực hiện chạy được test case trên nhiều trình duyệt, nhưng trong trường hợp em có một test suit gồm có hai test case : login và add-product được gom theo work flow (yêu cầu đăng nhập thành công mới có thể thực hiện add sản phẩm). Em thực hiện chạy test suit này trên chrome/IE thì sau khi chạy test case login -> đăng nhập thành công, chuyển sang chạy test case add-product thì tự động lại mở lên một browser mới -> test case này chạy bị fail do chưa đăng nhập. Vậy e muốn hỏi anh có cách nào để e có thể thực hiện chạy được test case add-product trên cùng một browser với test case login không ạ? hoặc có thể chạy test case add-product mà mặc định đã login sẵn vào hệ thống không ạ?
Mong anh có thể giải đáp giúp em ạ. Thanks anh!
LikeLike
Chào em, cách đơn giản nhất là em record chung cả 2 cái đó vào cùng 1 workflow. Thay vì em test chức năng login (1 testcase) và chức năng add-product (1 testcase) thì em gom chung vào trong 1 file.
Chức năng login sẽ là phần pre-condition hay còn gọi là khởi tạo data cho chức năng add-product. Dù sao thì Selenium IDE vẫn có nhiều hạn chế để xử lí những trường hợp này, em nên nghiên cứu thêm về testing framework như JUnit/ TestNG + testing tool (WebDriver) cho phần khởi tạo/ clean data test nhé.
Ví dụ: có hỗ trợ các annotation như @BeforeClass/ BeforeTest | @AfterClass/ AfterTest,..
LikeLike
EM chào anh ạ. Em làm theo như các bước của anh rồi cũng hiện ra thông báo đúng như Step 3 rồi những không hiểu sao lúc em chạy test case trên ID nó vẫn báo là “Could not connect to Selenium Server. Have you started the Selenium Server yet? ” Là lỗi gì đó ạ. Em cảm ơn ạ
LikeLike
Hi em,
Em check kĩ ở Step 4 là chọn đúng browser tương thích với driver ở step 3 nha.
Vd: ở step 3 em start selenium server + chrome driver thì step 4 phần Options > WebDriver em phải chọn chrome nhé.
LikeLike
a cho e hỏi e sử dụng chromedriver 2.33 và ie 3.6.0 với selenium-server-standalone-2.53.1 nhưng báo lỗi ạ
[code language="java" autolinks="true"]
[info] Executing: |clickAndWait | link=Add New | |
[error] element not visible
(Session info: chrome=61.0.3163.100)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'DESKTOP-LU8ISBT', ip: '172.16.143.189', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f), userDataDir=C:\Users\ASUS\AppData\Local\Temp\scoped_dir6420_9816}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=61.0.3163.100, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: 84a5abdef6735c648140195c34e6b3aa
[info] Executing: |selectFrame | id=content_ifr | |
[error] No frame element found by name or id content_ifr
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'DESKTOP-LU8ISBT', ip: '172.16.143.189', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: driver.version: unknown
[info] Executing: |runScript | document.getElementById("tinymce").innerHTML='duoi hinh bat chu , tro choi the hien do nhanh mat nhanh tay'; | |
[error] unknown error: Cannot set property 'innerHTML' of null
(Session info: chrome=61.0.3163.100)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 16 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'DESKTOP-LU8ISBT', ip: '172.16.143.189', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f), userDataDir=C:\Users\ASUS\AppData\Local\Temp\scoped_dir6420_9816}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=61.0.3163.100, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: 84a5abdef6735c648140195c34e6b3aa
[info] Executing: |selectFrame | relative=parent | |
[error] No frame element found by name or id relative=parent
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'DESKTOP-LU8ISBT', ip: '172.16.143.189', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: driver.version: unknown
[info] Executing: |type | id=title | tro choi moi |
[info] Executing: |clickAndWait | id=publish | |
[error] Element id=publish not found
[info] Executing: |clickAndWait | css=#view-post-btn > a.button.button-small | |
[error] Element css=#view-post-btn > a.button.button-small not found
[info] Executing: |clickAndWait | link=Post | |
[error] element not visible
(Session info: chrome=61.0.3163.100)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 56 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'DESKTOP-LU8ISBT', ip: '172.16.143.189', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f), userDataDir=C:\Users\ASUS\AppData\Local\Temp\scoped_dir6420_9816}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=61.0.3163.100, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: 84a5abdef6735c648140195c34e6b3aa
[info] Executing: |clickAndWait | link=All Posts | |
[error] element not visible
(Session info: chrome=61.0.3163.100)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 52 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'DESKTOP-LU8ISBT', ip: '172.16.143.189', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f), userDataDir=C:\Users\ASUS\AppData\Local\Temp\scoped_dir6420_9816}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=61.0.3163.100, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: 84a5abdef6735c648140195c34e6b3aa
[info] Executing: |clickAndWait | link=tro choi moi | |
[info] Executing: |clickAndWait | link=Log Out | |
[error] element not visible
(Session info: chrome=61.0.3163.100)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 48 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'DESKTOP-LU8ISBT', ip: '172.16.143.189', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f), userDataDir=C:\Users\ASUS\AppData\Local\Temp\scoped_dir6420_9816}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=61.0.3163.100, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: 84a5abdef6735c648140195c34e6b3aa
LikeLike
Hi em, trường hợp này xảy ra có 1 số nguyên nhân:
– Element em cần thao tác chưa dc visible tại step đó (thêm hàm waitForElementVisible trước)
– Các phiên bản trình duyệt và driver ko tương thích với nhau (chrome/ ie driver và selenium server), em nên sử dụng đúng version nhé (IE11/ Chrome mới nhất + driver mới nhất)
LikeLike
Dear a,
Cho e hỏi tí
Selenium chạy trên IE11 thì có out ra script ko a nhỉ
Dự án bọn e đang làm test trên IE11 cho Win 7 và Win 10
E đang muốn test IE11 trên win 7 dùng selenium out ra script, sau đó dùng script để chạy trên IE11 của Win 10 thì ko biết đc ko ?
LikeLike
Nếu ko dùng đc selenium thì có thể dùng đc cái gì a ạ ?
LikeLike
chào anh , anh có thể giúp em điều khiển profile coccoc được không
e có code
System.setProperty(“webdriver.chrome.driver”,
“C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe”);
ChromeOptions options = new ChromeOptions();
options.setBinary(“C:\\Users\\Administrator\\AppData\\Local\\CocCoc\\Browser\\Application\\browser.exe”);
options.addArguments(“user-data-dir=C:\Users\Administrator\AppData\Local\CocCoc\Browser\User Data\Profile 73”);
WebDriver driver = new ChromeDriver(options);
driver.get(“https://www.google.com.vn”);
driver.manage().window().maximize();
mà nó hiện ra một trình duyêt có 3 tap , không phải trình duyệt profile e cần ,HELP
LikeLike