Selenium 找不到 css/类名选择器

我正在为网站编写一个小型测试脚本,作为测试的一部分,程序需要单击按钮。我正在使用谷歌浏览器驱动程序,我尝试了一些功能,例如: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.il

When I click on sales section button

And I click on add family non gluten pizza button 

And I click on add button 

And I click on chosen extra

And I click on extra for the whole pizza

And I click on choose and next button

And I click on continue for payment allert button

And I click on continue for payment button 

Then I should successfully be moved to the payment form


吃鸡游戏
浏览 170回答 2
2回答

慕容3067478

请尝试以下:driver.findElement(By.xpath("//*[text()=\"לכל המבצעים\"]")).click();

慕桂英4014372

希望这会奏效//div[@class='home-page-actions_promotion-btn']//a
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java