I
I
itcry2019-04-21 21:59:47
C++ / C#
itcry, 2019-04-21 21:59:47

How to check for text in Selenium or PhantomJS + C#?

Hello. Tell me how to check for the presence of text in Selenium or PhantomJS + C#?
On the site, after clicking on the button, there can be 2 options for the text that will appear. Depending on the version of the text, you need to prescribe further actions. Selenium uses a chromedriver. I plan to switch to a phantom later, so that the tests are run in the background without opening the browser.
I can find the element on the loaded page by css selector, I pass the value of the text to the variable. But further, with the usual
IF (remennaya == "Text") the condition is not met, although I know for sure that the variable has the text that I set in the condition

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergey, 2019-04-22
@itcry

Regex.IsMatch(peremennaya.Trim(), "Text")
public static bool System.Text.RegularExpressions.Regex.IsMatch(string input, string pattern);
Summary: Indicates whether the specified regular expression finds a match in the specified input string.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question