【发布时间】:2021-11-17 19:57:34
【问题描述】:
我想自动加载 url 并获取登录按钮的控制权并在 Visual Studio 中使用 c# 将值传递给文本。我尝试使用 htmlagilitypack 获取控件并在文本框中传递值,我有使用硒网络驱动程序。我能够加载 url 并且无法获得登录按钮的控制并且无法在文本框中传递值。在这种情况下,有人可以帮助我吗?我在过去一周被困住了。我附上了我尝试过的示例代码。
using System;
using HtmlAgilityPack;
using System.IO;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Diagnostics;
using OpenQA.Selenium;
using OpenQA.Selenium.Edge;
using System.Threading;
using System.Threading.Tasks;
namespace HtmlAgilityPackTest
{
class Program
{
static void Main(string[] args)
{
//string driver = "Email";
string itext = "Sign In";
//string email = "Email";
//IWebDriver driver = new EdgeDriver();
var uri = "https://developer.servicenow.com";
var psi = new System.Diagnostics.ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = uri;
System.Diagnostics.Process.Start(psi);
//Thread.Sleep(3000);
var func = string.Format(@"document.getElementsByClass('dps-button-label').innerText = '{0}';",itext);
//Thread.Sleep(3000);
IWebDriver driver = new EdgeDriver();
IWebElement element = driver.FindElement(By.Name("form-control input-box username-box"));
element.SendKeys("xyz@gmail.com");
【问题讨论】:
标签: c# selenium-webdriver