T
T
TechNOIR2017-04-10 09:39:27
PowerShell
TechNOIR, 2017-04-10 09:39:27

Powershell. How to run Selenium in Webbrowser form?

Good afternoon, dear connoisseurs.
There is a code that calls the page through Firefox (accordingly, FF opens and the page loads):

[Reflection.Assembly]::LoadFrom("C:\selenium\net40\GeckoDriver.dll")
$url = "http://yandex.ru/"
$ie = New-Object OpenQA.Selenium.Firefox.FirefoxDriver
$ie.Navigate().GoToUrl($url)
$ie.Quit()

There is also a form on which the WebBrowser element:
Add-Type -AssemblyName System.Windows.Forms
$URL1 = ""

# WinForm Setup
$mainForm = New-Object System.Windows.Forms.Form
$mainForm.Font = “Comic Sans MS,9"
$mainForm.ForeColor = [System.Drawing.Color]::White
$mainForm.BackColor = [System.Drawing.Color]::DarkSlateBlue
$mainForm.Text = " System.Windows.Forms.WebBrowser Class"
$mainForm.Width = 960
$mainForm.Height = 750

# Main Browser
$webBrowser1 = New-Object System.Windows.Forms.WebBrowser
$webBrowser1.URL = $URL1
$webBrowser1.Width = 600
$webBrowser1.Height = 600
$webBrowser1.Location = "50, 25"
$mainForm.Controls.Add($webBrowser1)

# Display Form
[void] $mainForm.ShowDialog()

Question: Is it possible to make FF not open in a separate window, but broadcast through WebBrowser?
thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
azarij, 2017-04-10
@azarij

no, you can't. and if it is possible, then there are such dances with a tambourine ...
the web browser object works only through the Internet Explorer.
here they write that mozilla has its own, but I never worked with it: stackoverflow.com/questions/1949532/how-to-change-...
but even making it work, setting selenium on it would be hellish torment.
I think you overcomplicated your project. if you explained the end goal of the entire project, perhaps someone would suggest an easier way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question