Desired Capabilities and Chrome Options in Selenium WebDriver
Vložit
- čas přidán 21. 08. 2024
- In this video, I have explained about Desired Capabilities and Chrome Options in Selenium WebDriver.
Selenium WebDriver is an open-source tool for automated testing of web apps across many browsers.
DesiredCapabilities are a set of key-value pairs encoded as a JSON object. It helps QAs define basic test requirements such as operating systems, browser combinations, browser versions, etc. within Selenium test scripts. The DesiredCapabilities Class has multiple methods that let QAs specify the required properties regarding the desired test environments.
Not all server implementations will support every WebDriver feature. Therefore, the client and server should use JSON objects with the properties listed below when describing which features the user requests that session support. If a session cannot support a capability that is requested in the desired capabilities, no error is thrown; a read-only capabilities object is returned that indicates the capabilities the session actually supports.
Below three are the capabilities used by the selenium server for browser selection:
✔ browserName
✔ version
✔ platform
There are some read-only and red-write capabilities available in WebDriver, Apart from these capabilities, browser-specific capabilities are also available.
Chrome-Specific:
The WebDriver language APIs provides ways to pass capabilities to ChromeDriver. The exact mechanism differs from the language, but most languages use one or both of the following mechanisms:
✔ Use the ChromeOptions class. This is supported by Java, Python, etc.
✔ Use the DesiredCapabilities class. This is supported by Python, Ruby, etc. While it is also available in Java, its usage in Java is deprecated.
You can create an instance of ChromeOptions, which has convenient methods for setting ChromeDriver-specific capabilities. You can then pass the ChromeOptions object into the ChromeDriver constructor
Since Selenium version 3.6.0, the ChromeOptions class in Java also implements the Capabilities interface, allowing you to specify other WebDriver capabilities not specific to ChromeDriver.
To use DesiredCapabilities, you need to know the name of the capability and the type of value it takes.
Syntax:
-- Start Chrome maximized --
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
ChromeDriver driver = new ChromeDriver(options);
IE specific:
✔ ignoreProtectedModeSettings
✔ ignoreZoomSetting
✔ initialBrowserUrl
etc..
To get the list of desired capabilities, visit the below link:
github.com/Sel...
The following points can be covered in this video:
✔ desired capabilities in selenium webdriver for chrome
✔ desired capabilities in selenium webdriver for chrome java
✔ desired capabilities in selenium
✔ desired capabilities in selenium webdriver
✔ desired capabilities in selenium webdriver for ie 11
==============================================
************* Checkout my other playlists *************
==============================================
Java Programming videos playlist:👇
🔗 bit.ly/3keRJGa
Selenium WebDriver with Java videos playlist:👇
🔗 bit.ly/2FyKvxj
Selenium interview questions videos playlist:👇
🔗 bit.ly/3matUB3
Windows automation with FlaUI videos playlist:👇
🔗 bit.ly/33CG4dB
CSS Selectors videos playlist:👇
🔗 bit.ly/2Rn0IbD
XPath videos playlist:👇
🔗 bit.ly/2RlLdkw
Javascript Executor videos playlist:👇
🔗 bit.ly/2FhNXwS
Apache POI videos playlist:👇
🔗 bit.ly/2RrngrH
Maven videos playlist:👇
🔗 bit.ly/2DYfYZE
How to fix Eclipse errors:👇
🔗 bit.ly/3ipvNYf
==============================================
==============================================
Connect us @
🔗 Website - www.hyrtutorials.com
🔗 Facebook - HYRTutorials
🔗 LinkedIn - www.linkedin.com/company/hyrtutorials
🔗 Twitter - Hyrtutorials
==============================================
==============================================
🙏 Please Subscribe🔔 to start learning for FREE now, Also help your friends in learning the best by suggesting this channel.
#selenium #desiredCapabilities #chromeOptions #hyrtutorials #webAutomation
hyr tutorials,h y r tutorials,hyr,selenium webdriver tutorial,selenium tutorial,selenium tutorial for beginners,selenium training,selenium testing tutorial,automation testing tutorial for beginners,automation testing tools,selenium online training,selenium webdriver training,desired capabilities,capabilities,ChromeOptions,InternetExplorerOptions,AcceptInsecureCerts,start-maximized,incognito,selenium webdriver,
Please use the below link for the selenium videos playlist:
🔗 bit.ly/2FyKvxj
How to handle window authentication in chrome browser @H Y R
It can't be better than this!!! Great explanation! Keep doing more for the testing community.
Thankyou 😊
I was not able to understand the difference between two and was getting confused to read on net.. And found this video. You explained so well. Thanks a lot .. You are superb ..
Thankyou 😊
UNDOUBTADLY, I WOULD SAY U R NO1 TRAINER IN TESTING
Thanks buddy 😊
Awesome Explanation where its covering all confusion that many internet blog explained
Glad to hear that!
Great content !!! Can’t think any better than this
Thanks buddy 😊
Boss ...are you a IITian? of from which university u passed out?
you are really sooo knowledgeble abt the technpologies
great training approach
Thankyou
very neat explanation. Thanks
Thankyou 😊
Awesome jobs thank you so much you are life saver
Thankyou 😊
very well explained
Thanks buddy 😊
Was very helpful! Thanks loads!
Glad it helped buddy
Well explained
Thankyou buddy 😊
Very very helpful🙏
Thanks buddy 😊
Thank you
How to add same site by default cookies and Enable removing Same site= None cookies? What are keys to be added in option
didn't catch your question, can u elaborate a bit
@@HYRTutorials For my angular application I want to set 2 chrome flags mentioned above for Same Site cookies. I am not able to set the same using Chrome Option
I have already logged into google chrome, now how to load the profile and still keep the login status. Please guide me
Didn't catch you
@@HYRTutorials Great explanation sir. I guess my question and above question seems similar and it is: How to open a Chrome as different user ? Could you please guide me to perform this .
I have a doubt, while doing manual part.In chrome browser showing that plugins what are all you pinned but while doing automation it's does not shown why?.
In automation, a fresh instance of chrome browser will be opened.
Which does not have any configuration or data that is set/stored manually.
Well explained. Thank you.
I just wanted to ask you that, how can we set desired capabilities to accept alert automatically.?
Incase you are using the chrome browser, you can use the below code (use any one behavior from the below listed behaviors)
ChromeOptions options = new ChromeOptions();
options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.ACCEPT);
options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.DISMISS);
options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.IGNORE);
Incase if you are only looking for the desired capabilities, follow the below code:
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("unhandledPromptBehavior", "accept"); //accept,dismiss,ignore
desiredCapabilities.setCapability("unexpectedAlertBehaviour", "accept"); //accept,dismiss,ignore
Wow... It worked for me...thanks and lots of love 😍
@@devendrapawar2425 happy to help
If we want to maximize a browser window we can use driver.manage.window.maximize right then why to use capabilities class for maximize ?
driver.manage.window.maximize will maximize the browser after opening the browser but using caps we can do that while opening itself.
By your name I assume that you knew telugu language.
So please watch this video for better understanding.
czcams.com/video/POhpyNQeck8/video.html
I am facing an issue with permission based pop up !! I want to disable the pop up but it is not getting disabled !! Please help
watch this video:
czcams.com/video/deKXbbIHD4w/video.html
My project is working fine in eclipse but when I try to run on linux server it says [severe] bind failed cannot assign requested ip address (99)
I guess u need to check with your network team on this.
I am new to java. Is ChromeDriver class in the "chrome" package which is in the "selenium" package? i.e, everything except the right end are packages?
I didn't understand your question completely, could you elaborate it?
@@HYRTutorials when I write java.util.Scanner are "java", "util" called packages and "Scanner" is called a class?
Yes exactly.
There is no video for handling tables in selenium playlist
Tables are handled by using any dynamic locator like xpath or css selector.
In selenium we don't have a seperate mechanism to handle the tables.
We need to implement that logic by using the xpath or css selector.
I personally prefer xpath for tables
Do you have a video that teaches how to use Desired Capabilities and chrome Options in selenium grid?
Desired capabilities or chromeoptions won't change for selenium grid but for grid we can provide extra arguments while creating the nodes
Sir i am getting error when i gave Desiredcapabilities object 'caps' to chromedriver constructor at 7:33
What is the error buddy?
Send me the screenshot on hyadagirireddytutorials@gmail.com
I am facing issue on Jenkins while using webdriver manager, facing "Session not created issue" but the same setup was Working fine on local eclipse
Do u have any proxy or permission issues in Jenkins machine?
@@HYRTutorials Yes
@@HYRTutorials Now facing different issue like driver version : unknown , " after xpath faced this" . driver version issue due to xpath?
@@behondme9429 full error please
after login another browser is open and I want to click one button on that browser how do I handle this windows is same only URL name is change like first browser is logine when I login another URL dashboard is open and I a=want to click start button on this dashboard window
I have a video on how to handle window handles in this playlist buddy.
If you watch that video then you will be able to get your solution
Can we stop "save password" pop up when login with valid credential by using selenium automation? If yes then whats the code for that
Never tried that but take a look at the below link for all the chrome options:
src.chromium.org/viewvc/chrome/trunk/src/chrome/common/chrome_switches.cc?pathrev=291251
search for this one: // Prevents the save password bubble from being enabled.
I have read about this that with selenium 4 there are changes how desired capabilities work? but haven't fully understand it. Any good reference document or video suggestion to go through to understand it better with selenium 4 ?
There arent any particular changes in that area buddy. Selenium 4 has good support on chromedevtools protocol. May be you were confused with that.
Hi Sir, could you please also explain how to run selenium scripts on an already opened chrome browser
There are two scenarios:
1. utilizing manually opened chrome browser
2. utilizing chrome browser which is opened from selenium webdriver in the previous session.
We cant perform the scenario 1 but you can perform the scenario 2.
When u open any browser using automation, you will get the debug address of that browser.
using that you can run your script in next run.
Which chrome option is used to avoid the timeout render
Hello sir, Is there a way to block specific js in selenium v3, if so can you please provide some explanation
Why js needs to be blocked buddy?
how to take screenshots when there is an alert
In the same way how we take the page screenshots.
@@HYRTutorials that didn’t work, I googled and came to know about Robot class. Only then I was able to take the screenshot when an alert is there.
Ohh thats good
Hi sir,
In chrome mobile browser how to enable popup redirects so that popup is not blocking to another page by using the capabilities
I haven't worked on mobile browser bro
@@HYRTutorials
Ok In web browser how to enable the popup and redirects to allow through selenium bro once check and let me know bro
By default, it allows all the popups and will not block anything.
@@HYRTutorials
Thanks bro All the best for ur channel bro
@@chakradhargollamudi5557 Thankyou bro
caps is not wrorking for me
Which one buddy?
You can focus on the options instead of caps
Chrome opens with data; and stuck any have an Idea?
Wat is the error that you are getting in console?
Chrome opens with "Data;" with selenium
I'm getting this issue , please let me the solution if you have
Send me the screenshot on hyadagirireddytutorials@gmail.com
Command: [null, newSession {capabilities=[Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [], extensions: []}}], desiredCapabilities=Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [], extensions: []}}}]
Getting this error .., anyone can help ?
Send me the full error details along with the screenshot on hyadagirireddytutorials@gmail.com
Hi Sir, I am working on a project and I want to use chrome-driver with web-driver-manager. I have installed chrome, so do I need to install chrome binaries or is that provided by web-driver-manager
No need of chrome binaries.
webdriver manager will download the driver files for you.
@@HYRTutorials Thanks sir ..I had one more doubt ...should the chrome browser needs to be installed if I want to implement my project in "headless" mode?
Yes it should be installed
getting comile time excepyion as The constructor ChromeDruver(DesiredCapabilities) is undefined
Hi my chrome picking from local setting and not from my path in webddiver..
By default chrome browser requires the driver executable to communicate wit the browser.
so how is it opening the browser without using the driver exe?
are you trying to open the chrome browser which is installed in some other location?
@@HYRTutorials i mean to say it was showing wrong path in console.. Now it is fixed.. It was jar issue
Oh okay
👍👌
Thankyou 😊
For me the programme is not running properly .
What is the error you are facing buddy?
osam expalation
what about the
option.mearge what it do
If you have some desired capabilities created already and you want to merge those things also in the options class then you can use that merge method
How to handle window authentication in chrome browser @
You can use either autoit or robot class or sikuli
Hi thanks for the video, I have a question:
I am automating printing feature using selenium Java I have to deal with printing preview of chrome. I use chromeOptions to set some settings for printing like Save as PDF select landscape
I have one question I need to change paper size to A4 instead of letter that is the default but I don’t know the attribute to set, do you have an idea or have the documentation for print_preview_sticky_settings.appState ?
I try:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--kiosk-printing");
chromeOptions.setExperimentalOption("prefs", new java.util.HashMap() {{
put("plugins.plugins_disabled", new String[]{"Chrome PDF Viewer"});
put("printing.default_destination_selection_rules", "{\"kind\": \"local\", \"namePattern\": \"Save as PDF\"}");
put("printing.print_preview_sticky_settings.appState", "{\"recentDestinations\": [{\"id\": \"Save as PDF\", \"origin\": \"local\", \"account\": \"\" }],\"version\":2,\"isHeaderFooterEnabled\": true,\"paperSize\": 'A4',\"isGcpPromoDismissed\":false,\"selectedDestinationId\":\"Save as PDF\"}");
}});
Also I try media size parameter but not work also:
put("printing.print_preview_sticky_settings.appState", "{"recentDestinations": [{"id": "Save as PDF", "origin": "local", "account": "" }],"version":2,"isGcpPromoDismissed":false,"selectedDestinationId":"Save as PDF","mediaSize": {"height_microns": 355600,"width_microns": 215900,"is_default":true}}");
Hi sir, can you tell how to execute first or last or specific n no. Of feature files.
Like if I have 10 feature files and I want to execute 6 out of them. How can I do that
I'm assuming that you are talking about cucumber here.
You can provide the tags for those feature files and execute only those tags or you can mention the feature file names in your testrunner file
@@HYRTutorials we give tags for scenarios right. Can we also give tags for feature files. Can you paste sample code here
You can provide tag to the feature file also and it's exactly the same thing on how you do it for scenarios.
Im writing this comment from my mobile so I don't have the sample code handy.
It's easy only buddy. Just add the tag on top of feature keyword
@@HYRTutorials ok thank you so much for your reply
@@HYRTutorials and i need a small help. Can you share a sample demo project in which both cucumber and testng is used if give you my mail id. I want to know the structure which consists of both cucumber and testng. Ill be greatful to you if you provide one
How to create maven project
File - New - Maven project
Could you please explain this in python selenium too
As of now no plans for python buddy.
But will see if I can make a playlist on that also.
@@HYRTutorials okay...it will be very helpful for me 🙂
HYR 👍
Thankyou 😊
Bro I need your help ....
Tell me buddy
Hi Sir, i have written the same script but in incognito it is showing unsecure page even after merging both objects.
Can u send the screenshot on hyadagirireddytutorials@gmail.com
How to handle window authentication in chrome browser @H Y R
You can use any of the following:
AutoIT
Robot
Sikuli
Thank you @H Y R
Hi bro ,one more query .when I sheduled a run in remote server.autoit and robot scripts are failed to execute.plz help me vaild solution
U mean when u r running in parallel execution?
No it's not parallel execution
done
Thankyou 😊