[英]Selenium Webdriver - Relative xpath
我是 Selenium 的初學者。 我沒有任何動手經驗。 上個月,我報名參加了 Selenium 初級到高級課程,我幾乎沒有可以動手實踐的活動。
我被困在某個地方。 讓我解釋一下我的問題。
這是活動說明:
相對XpathLocator
網址: http ://webapps.tekstac.com/Shopify/
測試程序:
我為此編寫的代碼:
//Add required imports
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
public class RelativeXpathLocator //DO NOT Change the class Name
{
static String baseUrl = "http://webapps.tekstac.com/Shopify/";
public WebDriver createDriver() //DO NOT change the method signature
{
DriverSetup ds = new DriverSetup();
return ds.getWebDriver();
//Implement code to create Driver from DriverSetup and return it
}
public WebElement getRelativeXpathLocator(WebDriver driver)//DO NOT change the method signature
{
WebElement l = driver.findElement(By.xpath("//*[@id="tbrow"]/td[3]"));
return (l);
/*Replace this comment by the code statement to get the Web element */
/*Find and return the element */
}
public String getName(WebElement element)//DO NOT change the method signature
{
//Get the attribute value from the element and return it
}
public static void main(String[] args){
RelativeXpathLocator pl=new RelativeXpathLocator();
//Add required code
}
}
注意:卡在 Public Webelement getRelativeXpathLocator
現在,在我輸入代碼並檢查它是否拋出任何錯誤之后,我能夠看到 expect ")" ";" xpath 行中的錯誤。
我已經努力了幾個小時才能讓它發揮作用,但徒勞無功。
請指教。
謝謝。
錯誤是xpath
中的雙引號"
,所以更改xpath
從
driver.findElement(By.xpath("//*[@id="tbrow"]/td[3]"));
至
driver.findElement(By.xpath("//*[@id='tbrow']/td[3]"));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.