本文整理汇总了C#中OpenQA.Selenium.Chrome.ChromeDriver.ElementIsPresent方法的典型用法代码示例。如果您正苦于以下问题:C# ChromeDriver.ElementIsPresent方法的具体用法?C# ChromeDriver.ElementIsPresent怎么用?C# ChromeDriver.ElementIsPresent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Chrome.ChromeDriver
的用法示例。
在下文中一共展示了ChromeDriver.ElementIsPresent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
if (!File.Exists("settings.json"))
{
throw new Exception("settings.json file doesn't exist.");
}
settings = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText("settings.json"));
if (string.IsNullOrWhiteSpace(settings["steamUsername"]) || string.IsNullOrWhiteSpace(settings["steamPassword"]))
{
throw new Exception("Please provide your Steam username and password in settings.json.");
}
var options = new ChromeOptions();
options.AddArgument(string.Format("--user-data-dir={0}", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "userdata")));
options.AddArgument("--enable-file-cookies");
options.AddArgument("--disable-cache");
driver = new ChromeDriver(options);
directoryImgs = Path.Combine(directory, "images");
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
else
{
Array.ForEach(Directory.GetFiles(directory, "*.html", SearchOption.TopDirectoryOnly), File.Delete);
Array.ForEach(Directory.GetFiles(directoryImgs, "*.png", SearchOption.TopDirectoryOnly), File.Delete);
Array.ForEach(Directory.GetFiles(directoryImgs, "*.jpg", SearchOption.TopDirectoryOnly), File.Delete);
Array.ForEach(Directory.GetFiles(directoryImgs, "*.gif", SearchOption.TopDirectoryOnly), File.Delete);
}
driver.Navigate().GoToUrl("https://partner.steamgames.com/");
if (driver.ElementIsPresent(By.ClassName("avatar")))
{
signedIn = true;
}
else
{
Login();
}
if (signedIn)
{
if (settings.Keys.Contains("predefinedDocs"))
{
foreach (string predefined in settings["predefinedDocs"].Split(','))
{
var key = "https://partner.steamgames.com/documentation/" + predefined;
if (string.IsNullOrWhiteSpace(predefined) || documentationLinks.ContainsKey(key))
{
Console.WriteLine("Invalid or duplicate predefined doc: {0}", predefined);
continue;
}
cleanDocumentationLinks.Add(predefined);
documentationLinks.Add(key, false);
}
}
driver.Navigate().GoToUrl("https://partner.steamgames.com/home/steamworks");
GetDocumentationLinks();
AddFromSearchResults();
FetchLinks();
}
driver.Quit();
settings["predefinedDocs"] = string.Join(",", cleanDocumentationLinks);
File.WriteAllText("settings.json", JsonConvert.SerializeObject(settings, Formatting.Indented));
Console.WriteLine("Done.");
Console.ReadLine();
}