2016-05-12 71 views
0

我試圖找到一個窗體中的按鈕...但它沒有找到它... 我tryed使用threading.sleep(5000);但它不幫助。 我已經tryed了很多方法沒有任何幫助我總是說,它不能找到按鈕... 這裏是我的代碼:C#硒不能找到輸入形式

IWebElement startb2 = driver.FindElement(By.XPath("//form/*[@name='start']")); 

這裏是形式的html代碼:

<form method="post" action="php/PickFruits.php"> 
<input type="submit" name="start" value="התחל לקטוף" class="button_submit" style="margin-right:-97px;"> 
</form> 

我不想使用這個值,因爲它是用希伯來語編寫的......我不能在c#控制檯中使用它...請幫助我。

編輯:

現在它找到輸入的位置,但它不點擊它...代碼:

IWebElement startb = driver.FindElement(By.XPath("//*[@type='submit']")); 
startb.Click(); 
+0

嘗試的XPath = '// * [@類型= 「提交」]' –

+0

它的工作,但它不點擊它:L碼:IWebElement STARTB = driver.FindElement(By.XPath(「// * [@類型= '提交']「)); startb.Click(); –

+0

是否在點擊時給你一個錯誤? –

回答

0

要切換到一個iframe,使用下面的代碼。

//To find the iframe 
IWebElement Object = driver.FindElement(By.XPath("//*[@class='active_iframe']"); 
//To switch to and set focus to the iframe 
driver.SwitchTo().Frame(Object); 

然後執行點擊操作。

IWebElement startb = driver.FindElement(By.XPath("//*[@type='submit']")); 
startb.Click(); 
+0

無法正常工作...我的意思是沒有錯誤,只是沒有點擊... –

+0

什麼是我的iframe的xpath?我不知道:l iframe代碼: