0

I have a script which works for Firefox. Now I have to change it to chrome and run the automation in chrome. Everything is working except the ChromeProfile. I tried to do something like this;

import org.openqa.selenium.chrome.ChromeProfile as ChromeProfile

ChromeOptions options = new ChromeOptions()

options.setProfile(setChromeProfile())

and defining the function as;

def setChromeProfile() {
    ChromeProfile profile = new ChromeProfile()

    profile.setPreference('browser.helperApps.neverAsk.saveToDisk', 'application/json, text/html, application/xhtml+xml, application/xml, application/csv, text/plain, application/vnd.ms-excel, text/csv, text/comma-separated-values, application/octet-stream, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')

    profile.setPreference('browser.helperApps.neverAsk.openFile', 'application/json, text/html, application/xhtml+xml, application/xml, application/csv, text/plain, application/vnd.ms-excel, text/csv, text/comma-separated-values, application/octet-stream, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')

    profile.setPreference('browser.helperApps.alwaysAsk.force', false)

    profile.setPreference('browser.download.manager.showWhenStarting', false)

    profile.setPreference('browser.download.folderList', 2)

    profile.setPreference('browser.download.dir', 'C:\\Temp')

    profile.setPreference('pdfjs.disabled', true)

    profile.setPreference('layout.css.devPixelsPerPx', '0.9')

    return profile
}

Now, the error is with setProfile and the setPreference.

Error is something like this; startup failed: file:/C:/KatalonProjects/CAST_AutomationScripts-Working%202-2-2020/CAST_AutomationScripts-Working/Scripts/CASTProject-UniversalTestCase/Script1566846527176.groovy: 17: unable to resolve class org.openqa.selenium.chrome.ChromeProfile @ line 17, column 1. import org.openqa.selenium.chrome.ChromeProfile as ChromeProfile ^ The program is unable to recongnize the methods setProfile and the setPeference.

Thank you. Will be waiting for response.

  • And What is the error " error is with setProfile and the setPreference" ? Specifying error will help others to help you. – Rajat Feb 07 '20 at 16:04
  • Thank you for the reply. I have updated the question with the error. Basically program is unable to recognize the methods setProfile and the setPreference. – Deepti Baral Feb 07 '20 at 16:16

0 Answers0