Web applications for PSM. How to copy dynamic text from a webpage. How to show a Message box with the copied text inside it. How to copy a text inside the user PC Clipboard. Is there a way to not show the Webpage at all.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Welcome Idira to LIVEcommunity!

Our community just got stronger! Explore new identity security resources, connect with experts, and discover more ways to learn and collaborate.

Meet Idira

Web applications for PSM. How to copy dynamic text from a webpage. How to show a Message box with the copied text inside it. How to copy a text inside the user PC Clipboard. Is there a way to not show the Webpage at all.

L4 Transporter

Hello,

 

the Idea here to create a Connection components that login automatically, entries some data to generate a token then copy said token automatically into a Clipboard (token should also be displayed inside a box). No need to show the Chrome webpage.

 

 

Lets say we have this webpage https://practicetestautomation.com/practice-test-login/

Field_Content_versions_oct20__068Vy000012yYbbIAE.png 

I log in with

WebFormFields:

username>{Username}(SearchBy=id)

password>{Password}(SearchBy=id)

submit>(Button)(SearchBy=id)

 

after login I'm here:

Field_Content_versions_oct20__068Vy000012zCM4IAM.png 

I want to copy "Logged In Successfully" (or any dynamic text here) inside a box message

( so in this case I want to copy the text inside <h1 class="post-title">Logged In Successfully</h1> or //*[@id="loop-container"]/div/article/div[1]/h1).

 

My Questions:

  1. is there a copy command or a method?
  2. if we can copy, is there a way to display it inside a box?
  3. Can the text copied be automatically copied inside the user PC Clipboard?
  4. Can we do all this process without showing the Chrome webpage.

 

Thank you very much

1 accepted solution

Accepted Solutions

L5 Sessionator

Short answer: No — .INI files cannot perform extract web text or copy to clipboard.

However, You may try .ini file and Autoit to perform your required actions.

 

Sample code of Autoit as per your requirements:

 

#include "Selenium.au3" #include <MsgBoxConstants.au3> #include <Clipboard.au3>   ; ================================ ; READ FROM INI ; ================================ Local $url = IniRead("config.ini", "Login", "url", "") Local $username = IniRead("config.ini", "Login", "username", "") Local $password = IniRead("config.ini", "Login", "password", "")   Local $selUser = IniRead("config.ini", "Selectors", "username", "") Local $selPass = IniRead("config.ini", "Selectors", "password", "") Local $selSubmit = IniRead("config.ini", "Selectors", "submit", "") Local $selResult = IniRead("config.ini", "Selectors", "result", "")   ; ================================ ; START CHROME HEADLESS ; ================================ Local $ChromeOptions = _Selenium_CreateOptions() _Selenium_OptionsAddArgument($ChromeOptions, "--headless=new") _Selenium_OptionsAddArgument($ChromeOptions, "--disable-gpu")   Local $driver = _Selenium_Start("chrome", $ChromeOptions)   ; ================================ ; OPEN PAGE ; ================================ _Selenium_Navigate($driver, $url) Sleep(1000)   ; ================================ ; LOGIN ; ================================ Local $eUser = _Selenium_FindElement($driver, $selUser) _Selenium_ElementSendKeys($eUser, $username)   Local $ePass = _Selenium_FindElement($driver, $selPass) _Selenium_ElementSendKeys($ePass, $password)   Local $eSubmit = _Selenium_FindElement($driver, $selSubmit) _Selenium_ElementClick($eSubmit)   Sleep(2000)   ; ================================ ; EXTRACT RESULT TEXT ; ================================ Local $eResult = _Selenium_FindElement($driver, $selResult) Local $resultText = _Selenium_ElementGetText($eResult)   ; ================================ ; COPY TO CLIPBOARD ; ================================ _Clipboard_SetData($resultText)   ; ================================ ; SHOW IN MESSAGE BOX ; ================================ MsgBox($MB_ICONINFORMATION, "Result Copied", "Extracted Text:" & @CRLF & @CRLF & $resultText)   ; QUIT DRIVER _Selenium_Quit($driver)

View solution in original post

2 REPLIES 2

L5 Sessionator

Short answer: No — .INI files cannot perform extract web text or copy to clipboard.

However, You may try .ini file and Autoit to perform your required actions.

 

Sample code of Autoit as per your requirements:

 

#include "Selenium.au3" #include <MsgBoxConstants.au3> #include <Clipboard.au3>   ; ================================ ; READ FROM INI ; ================================ Local $url = IniRead("config.ini", "Login", "url", "") Local $username = IniRead("config.ini", "Login", "username", "") Local $password = IniRead("config.ini", "Login", "password", "")   Local $selUser = IniRead("config.ini", "Selectors", "username", "") Local $selPass = IniRead("config.ini", "Selectors", "password", "") Local $selSubmit = IniRead("config.ini", "Selectors", "submit", "") Local $selResult = IniRead("config.ini", "Selectors", "result", "")   ; ================================ ; START CHROME HEADLESS ; ================================ Local $ChromeOptions = _Selenium_CreateOptions() _Selenium_OptionsAddArgument($ChromeOptions, "--headless=new") _Selenium_OptionsAddArgument($ChromeOptions, "--disable-gpu")   Local $driver = _Selenium_Start("chrome", $ChromeOptions)   ; ================================ ; OPEN PAGE ; ================================ _Selenium_Navigate($driver, $url) Sleep(1000)   ; ================================ ; LOGIN ; ================================ Local $eUser = _Selenium_FindElement($driver, $selUser) _Selenium_ElementSendKeys($eUser, $username)   Local $ePass = _Selenium_FindElement($driver, $selPass) _Selenium_ElementSendKeys($ePass, $password)   Local $eSubmit = _Selenium_FindElement($driver, $selSubmit) _Selenium_ElementClick($eSubmit)   Sleep(2000)   ; ================================ ; EXTRACT RESULT TEXT ; ================================ Local $eResult = _Selenium_FindElement($driver, $selResult) Local $resultText = _Selenium_ElementGetText($eResult)   ; ================================ ; COPY TO CLIPBOARD ; ================================ _Clipboard_SetData($resultText)   ; ================================ ; SHOW IN MESSAGE BOX ; ================================ MsgBox($MB_ICONINFORMATION, "Result Copied", "Extracted Text:" & @CRLF & @CRLF & $resultText)   ; QUIT DRIVER _Selenium_Quit($driver)

 

@sanjay sah​ 

Thank you appreciated! I will try it

  • 1 accepted solution
  • 114 Views
  • 2 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!