I had an HTML button with id=submit so using Selenium IDE I selected the command "Click" with target as id=submit but selenium IDE pass this line as if it is executed but without the button really clicked so the form is not submitted !! what is wrong ?
Here is the C# code I exported. Problem is in driver.FindElement(By.Name("submit")).Click();
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
namespace SeleniumTests
{
[TestFixture]
public class Web
{
private IWebDriver driver;
private StringBuilder verificationErrors;
private string baseURL;
private bool acceptNextAlert = true;
[SetUp]
public void SetupTest()
{
driver = new FirefoxDriver();
baseURL = "I cannot share url";
verificationErrors = new StringBuilder();
}
[TearDown]
public void TeardownTest()
{
try
{
driver.Quit();
}
catch (Exception)
{
// Ignore errors if unable to close the browser
}
Assert.AreEqual("", verificationErrors.ToString());
}
[Test]
public void TheWebTest()
{
driver.Navigate().GoToUrl("I cannot share url");
driver.FindElement(By.Id("submit")).Click();
for (int second = 0;; second++) {
if (second >= 60) Assert.Fail("timeout");
try
{
if ("All Campaigns" == driver.FindElement(By.CssSelector("#CampaignsTable > div.box > div.title")).Text) break;
}
catch (Exception)
{}
Thread.Sleep(1000);
}
for (int second = 0;; second++) {
if (second >= 60) Assert.Fail("timeout");
try
{
if ("Last" == driver.FindElement(By.Id("cloaker_last")).Text) break;
}
catch (Exception)
{}
Thread.Sleep(1000);
}
driver.FindElement(By.XPath("(//img[@alt='Click to edit the rotator settings'])[1]")).Click();
driver.FindElement(By.Id("addNewUrl_0_geo_0_url_to_cloak")).Clear();
driver.FindElement(By.Id("addNewUrl_0_geo_0_url_to_cloak")).SendKeys("dghfghf");
driver.FindElement(By.Id("addNewUrl_0_geo_0_mobile_url")).Click();
driver.FindElement(By.Id("submit")).Click();
driver.FindElement(By.Id("submit")).Click();
for (int second = 0;; second++) {
if (second >= 60) Assert.Fail("timeout");
try
{
if ("Success" == driver.FindElement(By.CssSelector("div.message.green > span > b")).Text) break;
}
catch (Exception)
{}
Thread.Sleep(1000);
}
driver.FindElement(By.XPath("(//img[@alt='Click to edit the rotator settings'])[2]")).Click();
driver.FindElement(By.Id("addNewUrl_0_geo_0_url_to_cloak")).Clear();
driver.FindElement(By.Id("addNewUrl_0_geo_0_url_to_cloak")).SendKeys("tyujghghj");
driver.FindElement(By.Name("submit")).Click();
driver.FindElement(By.XPath("(//img[@alt='Click to edit the rotator settings'])[3]")).Click();
driver.FindElement(By.Id("addNewUrl_0_geo_0_url_to_cloak")).Clear();
driver.FindElement(By.Id("addNewUrl_0_geo_0_url_to_cloak")).SendKeys("gfhjghjgh");
driver.FindElement(By.Name("submit")).Click();
driver.FindElement(By.XPath("(//img[@alt='Click to edit the rotator settings'])[4]")).Click();
driver.FindElement(By.Id("addNewUrl_0_geo_0_url_to_cloak")).Clear();
driver.FindElement(By.Id("addNewUrl_0_geo_0_url_to_cloak")).SendKeys("ghghkghk");
driver.FindElement(By.Id("addNewUrl_0_geo_0_mobile_url")).Click();
driver.FindElement(By.Name("submit")).Click();
}
private bool IsElementPresent(By by)
{
try
{
driver.FindElement(by);
return true;
}
catch (NoSuchElementException)
{
return false;
}
}
private bool IsAlertPresent()
{
try
{
driver.SwitchTo().Alert();
return true;
}
catch (NoAlertPresentException)
{
return false;
}
}
private string CloseAlertAndGetItsText() {
try {
IAlert alert = driver.SwitchTo().Alert();
string alertText = alert.Text;
if (acceptNextAlert) {
alert.Accept();
} else {
alert.Dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}
}