With python I am trying to use the credentials provider to provide credentials when connecting to a website for automated GUI testing with selenium. I found the following page which explains how to do this, possibly for JAVA:
@Override
protected WebClient newWebClient() {
WebClient client = super.newWebClient();
DefaultCredentialsProvider provider = new DefaultCredentialsProvider();
provider.addCredentials("username","password");
client.setCredentialsProvider(provider);
return client;
}
I am trying to pythonize is, but I run into problems, and I do not find the appropriate class name fr the DefaultCredentialsProvider
:
from selenium import webdriver as original_webdriver
class webdriver(original_webdriver):
def newWebClient(self):
client = super().newWebClient()
provider = DefaultCredentialsProvider()
provider.addCredentials("username","password")
client.setCredentialsProvider(provider)
return client
The error when running this script is:
File "C:/Users/adi0341/PycharmProjects/SeleniumTest/tester.py", line 12, in <module>
class webdriver(original_webdriver):
TypeError: module.__init__() takes at most 2 arguments (3 given)
How to fix it? Or how to do something similar as explained in that link? Maybe there is an altogether different approach to provide authentication in order to open a web page for selenium automated GUI-testing?
P.S: The authentication will be an essential part of the testing itself. Logging in as different users and check access rights...