0

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();
11
  • try xpath = '//*[@type="submit"]' Commented May 12, 2016 at 9:09
  • it worked but it doesnt click on it :l code: IWebElement startb = driver.FindElement(By.XPath("//*[@type='submit']")); startb.Click(); Commented May 12, 2016 at 9:21
  • did it give you an error while clicking? Commented May 12, 2016 at 9:27
  • try adding some delay before you perform click operation. Commented May 12, 2016 at 9:30
  • I added but still nothing :l Commented May 12, 2016 at 9:34

1 Answer 1

1

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();
Sign up to request clarification or add additional context in comments.

4 Comments

what is the xpath to my iframe? I have no idea:l iframe code: <iframe src="actives/PickFruits.php" class="active_iframe"></iframe>
Added XPATH based on what you posted. Check now
but wait when I done with this Iframe how do I get back? I mean how i stop focus on that iframe and start looking on the all website?
driver.SwitchTo().DefaultContent(); you can use this to return back to top most frame on your page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.