I will try to be specific as possible as there is not a lot of code logic I can show. The application I am using I have created a customer within an application using RandomData that I don't know before hand. Once the customer is created there is a label that displays which i have captured via WebElement, for the sake of the example we will call it "lblWebElement". The Webelement is wrapped by a span id. in the span ID tags contains the data i am trying to capture to use for later. each piece of data is seperated by pipes so it looks like this:
location | ID | Name | Address | etc.
is there a way to capture each data point between the pipes and assign it a String Value to use for later?
You can get the text using below code:-
string text = driver.FindElement(By.Xpath("Your Xpath").Text;
To Split a String you can use:-
string[] values = text.Split('|');
Iterate on the array
to get different values.
Hope it helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.