我正在尝试访问网站,单击“联系我们”,然后在“询问购物者!”中搜索术语。搜索框。我试图在Selenium IDE中重新创建测试,但在录制时没有捕获搜索。我也不确定如何访问错误日志以诊断问题所在。到目前为止,我有:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Chrome;
namespace TestApplications
{
class Program
{
static void Main(string[] args)
{
IWebDriver driver = new ChromeDriver(@"C:\Library");
driver.Url = "http://www1.test.ca/en/Home";
var findContact = driver.FindElement(By.CssSelector("#Header > section.hdr-bar > div > div > menu > ul > li:nth-child(2) > a"));
findContact.Click();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
var findAsk = driver.FindElement(By.CssSelector("#response"));
findAsk.SendKeys("text");
}
}
}
因为在该页面中有一个具有相同ID iframe
的response
,而您的目标元素位于该具有相同ID的框架内。