Selenium 量角器测试需要包含两个或更多字符串

Selenium 量角器测试需要包含两个或更多字符串,selenium,selenium-webdriver,webdriver,jasmine,protractor,Selenium,Selenium Webdriver,Webdriver,Jasmine,Protractor,我需要一个量角器测试来测试两个可能的字符串。 我需要这样的东西: expect(element(By.css('.class')).getText().toContain(“字符串A”| |“字符串B”) 不确定如何实现这一点?您可以使用toMatch(): expect(element(By.css('.class').getText()).toMatch(/(string A|string B)/);

我需要一个量角器测试来测试两个可能的字符串。 我需要这样的东西:


expect(element(By.css('.class')).getText().toContain(“字符串A”| |“字符串B”)

不确定如何实现这一点?

您可以使用
toMatch()

expect(element(By.css('.class').getText()).toMatch(/(string A|string B)/);