简体   繁体   English

使用 VB.NET 在 Firefox 浏览器中单击特定链接

[英]Click a specific link in Firefox browser using VB.NET

I am new to coding and just started learning VB.net (because of background of VB6)我是编码新手,刚开始学习 VB.net(因为 VB6 的背景)

Now I am writing a simple program in VB.net which现在我正在 VB.net 中编写一个简单的程序

  1. Opens google.com in Firefox browser.在 Firefox 浏览器中打开 google.com。
  2. Searches for some query eg "ABC"搜索一些查询,例如“ABC”
  3. Clicks on a perticular link (eg abc.com) in search results.点击搜索结果中的特定链接(例如 abc.com)。

Now I have done part 1 and part 2 but I cant find a way to get a particlular link clicked.现在我已经完成了第 1 部分和第 2 部分,但我找不到点击特定链接的方法。

This is what I have tried uptil now这是我到目前为止尝试过的

Button1.Click
    Process.Start("C:\Program Files\Mozilla Firefox\firefox.exe", "https://www.google.com/")
    Threading.Thread.Sleep(5000) 
    SendKeys.SendWait("ABC")
    Threading.Thread.Sleep(500) 
    SendKeys.SendWait("~")
    Threading.Thread.Sleep(5000) 

Now how do I programmatically click on a particular href (eg abc.com).现在我如何以编程方式单击特定的href(例如abc.com)。

For some constraint I cannot use Webbrowser component for this program.由于某些限制,我不能为此程序使用 Webbrowser 组件。

Any guidance will be appreciated.任何指导将不胜感激。

I have recently been diving down this rabbit hole myself.我最近一直在自己潜入这个兔子洞。 I would suggest checking out: https://www.selenium.dev/selenium/docs/api/dotnet/ .我建议检查一下: https://www.selenium.dev/selenium/docs/api/dotnet/ There looks to be documentation for VB that could help.似乎有 VB 的文档可以提供帮助。 My application is written in C# so don't know if what I have written would have much crossover.我的应用程序是用 C# 编写的,所以不知道我写的内容是否会有很多交叉。

// This is example c# code for using selenium. 
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
static void Main(string[] args)
{
IWebDriver driver = new FirefoxDriver();
string url = "webpage.com";
driver.Navigate().GoToUrl(url);
Console.ReadLine();
driver.Quit();
}

Hope it helps.希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM