我正在为网站编写一个小型测试脚本,作为测试的一部分,程序需要单击按钮。我正在使用谷歌浏览器驱动程序,我尝试了一些功能,例如:driver.findElement(By.cssSelector()) driver.findElements(By.xpath()) 但由于某种原因程序无法识别定位器。在图像中,我选择了一个按钮来获取其 id 或类 (对不起,该网站是希伯来语的)。Main RunnerClass package runners; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; @RunWith(Cucumber.class) @CucumberOptions(features = { "src/test/java/featurefiles/" }, glue = { "stepDefinitions" }, monochrome = true, tags = {}, plugin = { "pretty", "html:target/cucumber", "json:target/cucumber.json", "com.cucumber.listener.ExtentCucumberFormatter:output/report.html" }) public class MainRunner {}特征文件 Feature: consume product through sales section. Scenario: payment form will display after assembling a product.Given I access pizzahut.co.ilWhen I click on sales section buttonAnd I click on add family non gluten pizza button And I click on add button And I click on chosen extraAnd I click on extra for the whole pizzaAnd I click on choose and next buttonAnd I click on continue for payment allert buttonAnd I click on continue for payment button Then I should successfully be moved to the payment form
2 回答
慕容3067478
TA贡献1773条经验 获得超3个赞
请尝试以下:
driver.findElement(By.xpath("//*[text()=\"לכל המבצעים\"]")).click();
添加回答
举报
0/150
提交
取消