2015-12-15 50 views
-1

我使用Selenium-webdriver(使用Java)自動化'facebook'嘗試將字符串發送到文本字段(作爲對帖子的評論)將導致打開幾個瀏覽器中的選項卡(chrome)以及瀏覽器的新窗口。 有沒有人遇到過這種奇怪的行爲?Sendkeys to Webelement導致新標籤窗口打開

這是我的代碼:

WebElement postBox = driver.findElement(By.xpath("(//div[contains(@title,'Write a comment')])[1]")); 
postBox.sendKeys("testing testing, 1.. 2.. 3.."); 
+2

請添加您的代碼,以便有人可以幫助您。 –

+0

@MattiasLindberg - 添加了我的代碼。 –

+0

它可能只是Facebook應用程序。你必須考慮它。 – sircapsalot

回答

0

我建議你用事實用cssSelector了XPath可以根據您的瀏覽器失敗。

CssSelector:By.CSSselector(.innerwrap textarea)

更多CSSselector here信息。