【发布时间】:2020-11-13 10:54:19
【问题描述】:
我正在导航到https://www.amazon.com/
我正在寻找 'samsung tv 55 inch' 在搜索框文本字段中设置它
然后我正在尝试提取(63 个结果 [见附图])的文本:
我找不到正确的定位器以及如何找到它,这是我的代码:
package com.bottomline.automation.tests.ui;
import com.bottomline.automation.pageobjects.model.AmazonWebPage;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class AmazonTest extends BaseTest {
AmazonWebPage amazonWebPage;
@BeforeClass
public void setup() {
amazonWebPage = new AmazonWebPage(driverWrapper);
}
@Test(priority = 10)
public void navigateToAmazonWebPage(){
amazonWebPage.navigateAndVerify();
}
@Test(priority = 20)
public void searchForHarryPotter(){
amazonWebPage.setSearchTextSearchBox("samsung tv 55 inch");
}
}
我正在努力寻找正确的定位器以获取结果文本
【问题讨论】:
-
您可能需要多个选择器,因为 AMZN 喜欢交替布局。
标签: java selenium xpath css-selectors webdriverwait