My project requires certain cookies to access the application. For Firefox Driver i am using firefox profile (profile of ff which i use for manual tetsing as it has all cookies i want) to run the script. How to run the same for Chrome and IE browsers. Is there any option to get the profiles of chrome and IE browser? Thanks in Advance
Chrome and IE driver profiles using webdriver
Asked Answered
IE doesn't support the notion of "profiles" like Firefox or Chrome. You'll need to create the cookies yourself, probably using the cookie API of WebDriver. –
Bost
I am using following code to invoke chrome profile, But this is not working. Please let me know what i am doing wrong System.setProperty("webdriver.chrome.driver", "C:\\Selenium framework\\Drivers\\chromedriver.exe"); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability("chrome.switches", Arrays.asList("--user-data-dir=C:\\Users\\admin\\AppData\\Local\\Google\\Chrome\\User Data\\Default")); capabilities.setJavascriptEnabled(true); _driver = new ChromeDriver(capabilities); –
Nuriel
This isn't possible with the profile-directories, since the IE, Firefox and Chrome ones are obviously different.
It should be possible by getting the cookies and porting to Chrome or IE to with the following commands:
cookies = driver.get_cookies() # to get all cookies
driver.add_cookie({"name": "key", "value": "value"}) # to add (port//set) cookies
Have look at docs for more information
© 2022 - 2024 — McMap. All rights reserved.