We are building a new experience for our SmartBear Community.
This site is now read-only. You can still browse and search as usual. Learn More
This site is now read-only. You can still browse and search as usual. Learn More
Hello. If someone can show me how to separate the Inner Text into individual variables.
Using the Spy tool, I am able to get the innerText, in this case it is a Store name, the ID and address but all in one.
I checked the other properties, it does not identify it separately. I image it's how the GUI has it displayed.
To work around it, Is it possible to separate the content found in the innerText, The information data are separated by common.
For instance,
StoreFullName = Aliases.browser.pageStoreX.FindElement("#current-store").innerText
Log.Message(StoreFullName);
Displays the full name: VisionOne, ID:12345678, One Main St.
But I would like to split each field into separate variables, Is it possible?
Log.Message(Store_Name) will display "VisionOne"
Log.Message(Store_ID) will display "12345678"
Log.Message(Store_Address) will display "One Main St. "
Screen shot of the example of the CSS , xpath copy is //*[@id="current-store"]/div[2]/div[2]/text()[1]
If it's comma seperated, then you can do something like this
function Split()
{
var str = "VisionOne, ID:12345678, One Main St.";
const arr = str.split(",");
for (var i = 0; i < arr.length; i++) {
Log.Message(arr[i]);
}
}It will be something like,
Project.Variables.MyVariable = arr[0]; // Store single value
Project.Variables.Var1 = arr; // Store array object
See https://support.smartbear.com/testcomplete/docs/testing-with/variables/collections/project-and-project-suite/index.html
If it's comma seperated, then you can do something like this
function Split()
{
var str = "VisionOne, ID:12345678, One Main St.";
const arr = str.split(",");
for (var i = 0; i < arr.length; i++) {
Log.Message(arr[i]);
}
}Thank you for help !!
Perfect, thanks for your help. 😀
Using your example, how can I add each string to a variable? Right now, I get each string in the message but how will I pass each message into a global variable
It will be something like,
Project.Variables.MyVariable = arr[0]; // Store single value
Project.Variables.Var1 = arr; // Store array object
See https://support.smartbear.com/testcomplete/docs/testing-with/variables/collections/project-and-project-suite/index.html