2015-02-11 58 views
1

我試圖實現Send sms的標籤,希望這張圖片能幫助你,我在找什麼。請see here如何使用Selenium選擇JavaScript選項卡?

所以,這裏是源代碼:

<li id="sendSMS" class="active"> 
    <a href="javascript:loadSMSPage('sendSMS');">Send SMS</a> 
</li> 

現在,我想這個源代碼:

driver.findElement(By.linkText("Send SMS")).click(); 

不幸的是,這是不工作 :(

請幫助,肯定會幫助,將不勝感激!

回答

1

我通常不依靠linkText那麼多嘗試使用xpath與基於文本的搜索

也試試這個

//li[@id='sendSMS']/a 

By byXpath = By.xpath("//a[.='Send SMS']"); 
WebElement myDynamicElement = (new WebDriverWait(driver, 10)) 
    .until(ExpectedConditions.presenceOfElementLocated(byXpath); 
myDynamicElement.click(); 

編輯: 新增explicit等待

+0

我什麼都試過花花公子。它說:'無法使用//a[.='Send SMS'找到節點]' – Robot 2015-02-11 16:46:27

+0

@Robot see edit – Saifur 2015-02-11 16:57:47

相關問題