Код: Выделить всё
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import org.apache.commons.io.FileUtils
import java.io.File
import java.util.concurrent.TimeUnit
try {
// Navigate to the webpage
WDS.browser.get("https://example.com")
// Wait for the page to load completely
WDS.browser.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS)
// Capture full-page screenshot using FireShot
String screenshotPath = "D:/API/fullpage_screenshot.png"
def screenshotBase64 = WDS.browser.executeScript("return FireShotAPI.base64EncodePage(true);")
byte[] decodedBytes = screenshotBase64.decodeBase64()
File screenshotFile = new File(screenshotPath)
FileUtils.writeByteArrayToFile(screenshotFile, decodedBytes)
// Log the screenshot path
WDS.log.info("Screenshot saved at: " + screenshotPath)
// Close the browser
WDS.browser.quit()
} catch (Exception e) {
WDS.log.error("Error capturing screenshot: " + e.getMessage())
}
2024-12-05 19:18:27,646 ОШИБКА c.g.j.p.w.s.WebDriverSampler: Ошибка захвата снимка экрана : ошибка JavaScript: FireShotAPI не определен
(информация о сеансе: chrome=131.0.6778.109)
Я хочу передать профиль Google, созданный с помощью плагина Fireshot, для запуска во время инициализации драйвера Chrome. Есть ли такой вариант?
Подробнее здесь: https://stackoverflow.com/questions/792 ... -in-jmeter
Мобильная версия