我使用自動化網絡硒驅動程序的頁面。我點擊一個元素。在控制檯中不會引發錯誤。元素正在被點擊,但在頁面上沒有可見的影響。我嘗試了很多其他元素,但面臨同樣的問題。每個元素都顯示爲點擊,但沒有影響。點擊動作,但不影響顯示在頁面中硒
示例方案。我是通過單擊元素上的星形圖標來爲元素添加書籤的。點擊時,星星應該變成藍色。當執行的控制檯顯示元素被書籤時,即點擊星號。但在頁面上,該部分不會變成藍色。但它刷新頁面,明星是藍色的。
請幫助我的人可能是什麼問題?
// Method to add a part to bookmarks on results panel
public void addPartToBookmarksOnResultsPanel(String partName)
throws OnePartException {
helper = new HelperClass(driver);
String trimmedPartName = partName.trim();
// get the count of search results
int resultsCount = helper.getResultsCount();
boolean matchFound = false;
// get all the search results and iterate through them to find the
// required part to be bookmarked.
for (int i = 1; i <= resultsCount; i++) {
// Get the name of the part to be bookmarked
String part = driver
.findElement(
By.xpath("//div[@class='widgetContent']//div[" + i
+ "]//div//div[2]//div//h3//a")).getText()
.trim();
// if obtained part name is same as expected part name, then
// click
// corresponding part's bookmark icon.
if (part.equalsIgnoreCase(trimmedPartName)) {
matchFound = true;
// Check whether the part is already bookmarked or not
String bookmarkStatus = driver.findElement(
By.xpath("//div[@id='resultList']/div/div[" + i
+ "]/div/div[2]/div/div/div[2]/span"))
.getAttribute("class");
// If already bookmarked, then show the message
if (bookmarkStatus.equalsIgnoreCase("addToBasket active")) {
logger.info("Part" + trimmedPartName
+ "is already bookmarked");
} else {
click(driver.findElement(By
.xpath("//div[@id='resultList']/div/div[" + i
+ "]/div/div[2]/div/div/div[2]/span/span")));
// Check whether notification is displayed
String bookmarkSuccessNotofication = helper
.getNotificationMessage();
logger.info("part "
+ partName
+ " is suucessfully bookmarked and notification reads "
+ bookmarkSuccessNotofication);
// Thread.sleep(6000);
}
break;
}
}
// If part is not found in the results, throw an error
if (!matchFound) {
logger.error("Part " + partName
+ " is not found in the Results. Error in bookmarking it");
throw new OnePartException("Part " + partName
+ " is not found in the Results. Error in bookmarking it");
}
}
請粘貼代碼 –
我覺得沒有必要的代碼。這是簡單的點擊工作,但不影響頁面。沒有代碼的 –
沒人能幫忙嗎?我們能想象你的問題,但沒有代碼 –