oren ben yamin
oren ben yamin

Reputation: 21

C# selenium cant find input in form

I am trying to locate a button in a form... but it doesnt find it... I have tryed using threading.sleep(5000); but it dont help. I have tryed so many ways but nothing helped me it always says that it cant locate the button... here is my code:

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

here is the html code of the form:

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

I don't want to use the value because it is in Hebrew... and I cant use it in the c# console... please help me guys.

Edit:

Now its find the location of the input but it doesnt click on it... code:

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

Upvotes: 0

Views: 3120

Answers (1)

Hassan Mehmood
Hassan Mehmood

Reputation: 1402

To switch to an iframe, use the below code.

//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);

And then perform click operation.

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

Upvotes: 1

Related Questions