我有这个脚本可以在Internet Explorer中打开某些网站,我也想在Chrome上使用它,但由于-ComObject而无法适应它
$navOpenInBackgroundTab = 0x1000;
$IE = New-Object -ComObject InternetExplorer.Application
$IE.navigate2("http://website.com");
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.navigate2("http://website.com", $navOpenInBackgroundTab);
$IE.Visible = $true
谢谢您的时间
答案 0 :(得分:1)
Start-Process "chrome.exe" "www.google.com"
您可以按名称启动进程,甚至可以像上面那样向其传递参数(URL)
答案 1 :(得分:0)
您可以使用硒并执行以下操作:
Add-Type -Path "C:\Automation\Selenium\Selenium.WebDriverBackedSelenium.dll"
Add-Type -Path "C:\Automation\Selenium\ThoughtWorks.Selenium.Core.dll"
Add-Type -Path "C:\Automation\Selenium\WebDriver.dll"
Add-Type -Path "C:\Automation\Selenium\WebDriver.Support.dll"
$driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver
$driver.Navigate().GoToUrl("https://www.google.com/")
$driver.Navigate().GoToUrl("https://www.google.com/")
$driver.Navigate().GoToUrl("https://www.google.com/")
$driver.Quit();
要获取dll,您可以执行以下操作:
在桌面上,加载Visual Studio并添加以下Nuget程序包。
Selenium.WebDriverBackedSelenium
Selenium.WebDriver
Selenium.Support
Selenium.RC
Selenium.Chrome.WebDriver
转到nuget软件包文件夹,然后将以下dll和exe复制到名为C:\Automation\Selenium
的文件夹中: