Severity: Notice
Message: Trying to access array offset on value of type bool
Filename: drivers/Cache_file.php
Line Number: 277
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 121
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Post.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
Severity: Notice
Message: Trying to access array offset on value of type bool
Filename: drivers/Cache_file.php
Line Number: 277
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 123
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Post.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
Severity: Warning
Message: file_get_contents(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeyfacebook.cache): failed to open stream: No such file or directory
Filename: drivers/Cache_file.php
Line Number: 275
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 126
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Post.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
Severity: Notice
Message: Trying to access array offset on value of type bool
Filename: drivers/Cache_file.php
Line Number: 277
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 126
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Post.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeyzalo.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 128
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Post.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeyqr_zalo_group.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 129
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Post.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeyyoutube.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 132
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Post.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
Severity: Warning
Message: file_get_contents(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeybanner_footer.cache): failed to open stream: No such file or directory
Filename: drivers/Cache_file.php
Line Number: 275
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 137
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Post.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
Severity: Notice
Message: Trying to access array offset on value of type bool
Filename: drivers/Cache_file.php
Line Number: 277
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 137
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Post.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
Bước 1: Mở IntelliJ và chọn File > New > Project
Bước 2: Chọn tab New Project và nhập thông tin như mẫu
🔆 Các bạn chú ý:
Để cài đặt thư viện Selenium vào Maven project thì các bạn sẽ cài nó vào file pom.xml
Thư viện sẽ được lấy tại đây: https://mvnrepository.com/
Chúng ta cần cái gì thì search cái đó rồi copy bỏ vào file pom.xml và build lại maven project là xong.
🔆 Ví dụ cài Selenium
Khi dán vào pom.xml nhớ để trong cặp thẻ <dependencies> </dependencies>
Dán thư viện vào xong nhớ reload project lại bằng cách nhấn vào biểu tượng Reload hoặc right click > maven > reload project
Các bạn tạo 1 class bất kỳ ở package test (không tạo bên package main) và nhập từ khoá WebDriver. Nếu nó gợi ý hiển thị lên như hình là đã cài đặt được Selenium thành công.
Sau khi thêm thư viện Selenium vào file pom.xml các bạn nhớ nhấn build lại Maven nhé.
File pom.xml hiện tại như này:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>anhtester.com</groupId>
<artifactId>SeleniumMaven</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.22.0</version>
</dependency>
</dependencies>
</project>
Các bạn tạo 1 class ví dụ TestSelenium và dán đoạn code này vào:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.time.Duration;
public class TestSelenium {
public static void main(String[] args) {
//Khởi tạo browser với Chrome
WebDriver driver;
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
//Mở trang anhtester.com
driver.get("https://anhtester.com/");
//Click nút Login
driver.findElement(By.xpath("//a[@id='btn-login']")).click();
//Tắt browser
driver.quit();
}
}
Yeah vậy là xong rồi 😋
Các bạn cũng add thư viện vào pom.xml tương tự Selenium nhé
Add xong nhớ nhấn Reload Maven Project lại nhe.
Xong các bạn tạo class mới vào gọi ghi chú @Test
nếu nó hiện như hình bên dưới là ok.
Yeah vậy là xong rồi 😋
Anh Tester
Đường dẫu khó chân vẫn cần bước đi
Đời dẫu khổ tâm vẫn cần nghĩ thấu