Automating the process to get access token
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Automating the process to get access token
We have to click on "Auth" tab
2. Click on "Get Access Token"
3. Click on "Get Access Token" again
4. Wait for SoapUI Browser to open to manually enter in the data and click "Login to Application "
From there we now can run all the Requests solution for the Automation section in the "Get Access Token" section > Automation... Button where you can put a page 1 or page 2 script. (none of the online examples worked for Salesforce)
or
or
b. A Groovy way to do the above
or
c. To Generalize - we don't want to have to manually do the above 1-4 steps
Please suggest me how to automate the above 1-4 steps.
- Labels:
-
Academy
-
CommunityNews
-
Interview
-
ReadyAPITeam
-
Webinar
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can we directly leverage the Salesforce API instead? If we could ping the service and request authentication through an API call, I think it would provide more room for automation.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I created the script for it. You need to know the email, password, login button element locators. Now the system automatically opens the login page> fill in all the info and click the login button when the token expired
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much @aihnatsiuk !
@SoapuiTeay Does the solution work for you? Please let us know!
Sonya Mihaljova
Community and Education Specialist
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you have separate /token for oauth2, then you are able to create a scripts to dynamically get access_token.
FYI
import groovy.json.JsonSlurper
def data = new JsonSlurper().parseText(response) // get response of token
// set access token
def authProfileName = "LoginToken"
def project = testRunner.testCase.testSuite.project
def profile = project.getOAuth2ProfileContainer()
if (! (authProfileName in profile.getOAuth2ProfileList().name)) {
profile.addNewOAuth2Profile(authProfileName) // add new oauth2
}
def auth = profile.getProfileByName(authProfileName)
auth.setAccessToken(data.access_token) // set token
project.setAuthProfile(authProfileName) // applied in project level
Then you can select "LoginToken" for your request in test step or changed it in Auth manager
Thanks,
/Aaron
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could you send the click button function in your code? my example
function click(){
document.querySelector("HERE YOUR CSS SELECTOR").click();
}
