最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Why am I getting this error No such property: chromeDriverPath for class: com.kms.katalon.core.webui.driver.DriverFactory

programmeradmin2浏览0评论

I'm new to Katalon, groovy and has very basic understanding of Java. I keep on getting this error after I update the drivers.

Q: Why am I getting this error? How can I fix this?

Error:

Reason:
groovy.lang.MissingPropertyException: No such property: chromeDriverPath for class: com.kms.katalon.core.webui.driver.DriverFactory
    at utils.Browser.setPreferences(Browser.groovy:107)
    at utils.Browser.openBrowser(Browser.groovy:39)

Code:

public class Browser {
    
    private static CommonObjects.NavigationBar NAVIGATION_BAR_OBJECTS = new CommonObjects.NavigationBar()
    
    public static void openBrowser(String url) {
    
        new Browser().setPreferences()
    
        deleteAllCookies()
        goTo(url)
        maximizeWindow()
        delay(3)
        String pageTitle = getWindowTitle().trim()
        logInfo("Navigated to [" + pageTitle + "].")
        delay(2)
    }
    
    
    public static void setPreferences() {
        String downloadPath = ReviewConstants.FolderDirectories.DOWNLOAD
        KeywordUtil.logInfo("The download path is [" + downloadPath + "].")
    
        // The necessary preferences to set.
        Map<Object, String> prefs = new HashMap<Object, String>()
        prefs.put("download.default_dictionary", downloadPath)
        prefs.put("download.direcory_update", true)
        prefs.put("download.prompt_for_download", false)
        prefs.put("browser.download.dir", downloadPath)
        prefs.put("download.default_directory", downloadPath)
        prefs.put("profile.content_settings.exceptions.automatic_downloads.*.setting", 1) // Allow multiple downloads without prompt
    
        KeywordUtil.logInfo("The browser is [" + DriverFactory.getExecutedBrowser().getName() + "].")
    
        switch (DriverFactory.getExecutedBrowser().getName()) {
            case "CHROME_DRIVER" :
   
                System.setProperty('webdriver.chrome.driver', DriverFactory.chromeDriverPath)
                ChromeOptions chromeOptions = new ChromeOptions()
                chromeOptions.setExperimentalOption("prefs", prefs)
                DriverFactory.changeWebDriver(new ChromeDriver(chromeOptions))
                break
    
            default:
                throw new Exception("Failed to set the preferences. Browser may be incompatible.")
        }
    }
}

Update the webdriver.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论