2017-01-08 1 views
0

Selenium IDE를 사용하여 id가 submit 인 HTML 버튼이 있습니다. 대상을 id = submit로 선택했지만 셀이없는 IDE는이 행을 실행하지만 버튼은없는 것처럼 전달합니다 정말 클릭하면 양식이 제출되지 않습니다 !! 뭐가 잘못 되었 니 ?Selenium이 클릭 명령을 실행하지 않음

다음은 내가 내 보낸 C# 코드입니다. 문제는 당신이 코드를 기존 공유하는 경우, URL이 우리가 더 도움이 될 수있는 등, 참조하려고 아마 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; 
      } 
     } 
    } 
} 

답변

0

입니다.

충분한 정보없이 질문에 대답하기가 어렵습니다.

0

코드를 공유하지 않았으므로 문제를 분석하기가 어렵습니다. 도움이 될 수도 있습니다 -

clickclickAt으로 변경 한 다음 시도해보십시오.

+0

동일한 문제는 IDE를 사용합니다. – Wel

관련 문제