Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeymessenger_id.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: 127
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_SelectByKeymeta_image.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: 144
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: 144
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
@Test
public void handleChatboxMessenger() {
driver.navigate().to("https://anhtester.com/contact");
sleep(10);
System.out.println("iframe total: " + driver.findElements(By.tagName("iframe")).size());
//----Switch to content of Messenger--------
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@data-testid='dialog_iframe']")));
//Get title
System.out.println(driver.findElement(By.xpath("//strong")).getText());
//Get description
System.out.println(driver.findElement(By.xpath("(((//strong/parent::div)/parent::div)/following-sibling::div)[2]")).getText());
//----Switch to icon of Messenger---------
//1. Switch to Parent WindowHandle
driver.switchTo().parentFrame();
//2. Switch to iframe icon of Messenger
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@data-testid='bubble_iframe']")));
driver.findElement(By.tagName("svg")).click(); //Nhấn icon để ẩn messenger chat đi
sleep(2);
}
- Bước 1: Đếm số iframe xem website mình có tổng số mấy cái để có gì chúng ta lấy theo vị trí của iframe khi nó không có thuộc tính nào cả (đường cùng)
driver.findElements(By.tagName("iframe")).size()
- Bước 2: Xác định cái Dialog bên trên của Messenger:
//----Switch to content of Messenger--------
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@data-testid='dialog_iframe']")));
Lấy text của title và description
System.out.println(driver.findElement(By.xpath("//strong")).getText());
System.out.println(driver.findElement(By.xpath("(((//strong/parent::div)/parent::div)/following-sibling::div)[2]")).getText());
- Bước 3: Xác định cái Icon bên dưới của Messenger:
Chúng ta phải switch về cái frame chính default vì nó đang trỏ đến frame của dialog bên trên.
Sau đó mới switch đến icon của messenger sau.
//1. Switch to Parent WindowHandle
driver.switchTo().parentFrame();
//2. Switch to iframe icon of Messenger
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@data-testid='bubble_iframe']")));
Nhấn icon với thẻ svg cho dễ
//Nhấn icon để ẩn messenger chat đi
driver.findElement(By.tagName("svg")).click();

🌱 Facebook
Fanpage: Anh Tester
🌱
Telegram Automation Testing:
Cộng đồng Automation Testing
🌱 Facebook Group Automation:
Cộng đồng Automation
Testing Việt Nam
🌱
Telegram Manual Testing:
Cộng đồng Manual Testing
🌱 Facebook
Group Manual:
Cộng đồng Manual Testing Việt Nam
Copyright © 2021-2025 Anh Tester Automation Testing
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