我的程序中有数字触摸板(1-9),需要测试的地方是检查用户何时键入以结尾结尾的数字: 1到9 例如0,01 / 0,33 / 4,46,则系统会引发通知:“无效价格”
数字只能以5或0结尾,然后才有可能付款。
作为Selenium初学者,我不知道该怎么做。我从这些字段中获取字符串值开始
: var number1 = driver.FindElement(By.XPath("//div[@class='numpad-button primary-button' and contains(.,'1')]")).Text;
var number2 = driver.FindElement(By.XPath("//div[@class='numpad-button primary-button' and contains(.,'2')]")).Text;
var number3 = driver.FindElement(By.XPath("//div[@class='numpad-button primary-button' and contains(.,'3')]")).Text;
var number4 = driver.FindElement(By.XPath("//div[@class='numpad-button primary-button' and contains(.,'4')]")).Text;
var number6 = driver.FindElement(By.XPath("//div[@class='numpad-button primary-button' and contains(.,'6')]")).Text;
var number7 = driver.FindElement(By.XPath("//div[@class='numpad-button primary-button' and contains(.,'7')]")).Text;
var number8 = driver.FindElement(By.XPath("//div[@class='numpad-button primary-button' and contains(.,'8')]")).Text;
var number9 = driver.FindElement(By.XPath("//div[@class='numpad-button primary-button' and contains(.,'9')]")).Text;
有任何提示吗?
答案 0 :(得分:0)
通过单击相关元素尝试进行非法排序:
WebElement number2 =
driver.findElement(By.xpath(
"//div[@class='numpad-button primary-button' and contains(.,'2')]"));
WebElement quote =
driver.findElement(By.xpath(
"//div[@class='numpad-button primary-button' and contains(.,',')]"));
WebElement submit =
driver.findElement(By.xpath(
"//div[@class='numpad-button primary-button' and contains(.,'submit')]"));
// Test invalid price
number2.click();
number2.click();
quote.click();
number2.click();
number2.click();
submit.click();
// Test expected exception here
该代码是Java语言,因此需要您进行C#调整。