代碼:使用XPath定位按鈕 - JAVA /硒2在Chrome背後的按鈕
<input class=」btn」 id=」mypage:formid:relatedScenaiosListId:j_id27:j_id28″ name=」mypage:formid:relatedScenaiosListId:j_id27:j_id28″ onclick=」window.open(‘/apex/newscenario?Opportunity__c=006f00000072n8hAAA’,’_top’, 1);;A4J.AJAX.Submit(‘mypage:formid’,event,{‘similarityGroupingId’:’mypage:formid:relatedScenaiosListId:j_id27:j_id28′,’parameters’:{‘mypage:formid:relatedScenaiosListId:j_id27:j_id28′:’mypage:formid:relatedScenaiosListId:j_id27:j_id28′} });return false;」 value=」New」 type=」button」>
我沒有從檢查元素視圖中點擊右鍵,看到我可以複製的XPath和發現它是:
//*[@id="mypage:formid:relatedScenaiosListId:j_id27:j_id28"]
注意*。
我累了:
WebElement txtnew = driver.findElement(By.xpath(「//input[@id='mypage:formid:relatedScenaiosListId:j_id27:j_id28']「));
txtnew.click();
和
WebElement txtnew = driver.findElement(By.xpath(「//input[@id='mypage:formid:relatedScenaiosListId:j_id27:j_id28'][@value='New']「));
txtnew.click();
但既不工作。
我很好奇*,如果這應該是我的Xpath語句的一部分?
你是什麼意思的「不工作」 - 任何錯誤? – alecxe 2014-08-28 22:42:48