Skip to content

Feature/v4 driverupgrade #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions Help/ConvertTo-SeSelenium.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
external help file: Selenium-help.xml
Module Name: Selenium
online version:
schema: 2.0.0
---

# ConvertTo-Selenium

## SYNOPSIS
Convert Selenium IDE .side recording file to PowerShell commands.

## SYNTAX

```
ConvertTo-Selenium [-Path] <String> [<CommonParameters>]
```

## DESCRIPTION
{{ Fill in the Description }}

## EXAMPLES

### Example 1
```powershell
PS C:\> {{ Add example code here }}
```

{{ Add example description here }}

## PARAMETERS

### -Path
Path to .side file.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

## OUTPUTS

## NOTES

## RELATED LINKS
2 changes: 1 addition & 1 deletion Output/Selenium/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#4.0.0 (Unreleased)


# 4.0.0-beta-1 (Prerelease)
# 4.0.0-preview1 (Prerelease)
Note: V4 have an enormous amount of breakchanges. Most of the cmdlet have been rewriten in a way or another.

Duplicate functions have been eliminated along with all aliases that piled up over time. Start-SeDriver provide an unified front to start all the browsers and the $Driver parameter / default driver are no more. Instead, starting a driver make it the active driver. Switching active driver can be accomplished through the Switch-SeDriver cmdlet.
Expand Down
87 changes: 36 additions & 51 deletions Output/Selenium/Examples/A-Simple-Google-Search.ps1
Original file line number Diff line number Diff line change
@@ -1,70 +1,55 @@
<#
.VERSION - 0.2

.DESCRIPTION
This is an example script that will show you how to use the Selenium driver to preform a simple google search.
Using this example script you will learn the basic usage of the Selenium powershell module.
Each comment line will explain the line that will come after it so you can follow it in a step by step fashion.
#>

# The line below will Import-Module Selenium if it fails it will display the installation command and stop the script.
try{Import-Module -Name Selenium -ErrorAction Stop}catch{Write-Host 'Importing the Selenium module failed. Please install it using the following command: Install-Module Selenium';break}
Import-Module -Name Selenium

# Start the Selenium Chrome Driver
$Driver = Start-SeChrome
Start-SeDriver -Browser Chrome -StartURL 'google.com/ncr'

# Next we will check if the driver is running and if it's not running we will show a message. If the driver is running we will run the commands inside the if statment.
if($Driver){
# Now that we verified that the driver is running we can start doing cool things with it.

# Using the Enter-SeUrl command we can tell the driver to go to any URL we want in this case we'll go to https://google.com/ncr
# I used the /ncr in the end of the URL because I want google to always stay in english and not redirect to a specific language for consistency.
Enter-SeUrl -Driver $Driver -Url 'https://www.google.com/ncr'

# After nevigating to the desired URL we can start interacting with elements on the page in this example we are going to find the search box and type something in it.
# We can find elements using different ways like the element id or the Name/ClassName/TagName and a few other ways.
# In the below code we're going to show you a few ways to solve this problem.
#Getting the Search box

<# This is the HTML code of the search box
<# This is the HTML code of the search box, found using the browser developer tools
<input class="gLFyf gsfi" maxlength="2048" name="q" type="text" jsaction="paste:puy29d" aria-autocomplete="both" aria-haspopup="false" autocapitalize="off" autocomplete="off" autocorrect="off" role="combobox" spellcheck="false" title="Search" value="" aria-label="Search">
#>
#>

# By examining the HTML code of the google seach box we can see that the search box name is q so in the below example we'll use the name q to find its element
$SearchBoxElement = Find-SeElement -Driver $Driver -Name q
#Here's a few different ways, all valid, to access that searchbox

# We can also use the class name gLFyf to find the google search box.
$SearchBoxElement = Find-SeElement -Driver $Driver -ClassName 'gLFyf'
# By examining the HTML code of the google seach box we can see that the search box name is q so in the below example we'll use the name q to find its element
#The Single parameter will write an error if there's not 1 element.
$Searchbox = Get-SeElement -By Name -value q -Single

# This line will get us all elements with the input TagName also known as <input>
$AllInputElements = Find-SeElement -Driver $Driver -TagName input
# We can also use the class name gLFyf to find the google search box.
$Searchbox = Get-SeElement -ClassName 'gLFyf'

# The $AllInputElements contains all the input elements on the page if we want to find the specific element for the google search box we will need to loop through each input element in the $AllInputElements array and get the attibute we want in this case we're looking for the title attribute.
# And we only want to return the element that has a title equal to Search we can find this out based on the html code on the page.
$SearchBoxElement = $AllInputElements|ForEach-Object{if($_.GetAttribute('title') -eq 'Search'){return $_}}
# This line will get us all elements with the input TagName also known as <input>
#The -All parameter (optional) also includes hidden elements.
# The -Attributes parameter will load the specified attribute in the result and make them available through an Attributes property
$AllInputElement = Get-SeElement -By TagName -Value input -All -Attributes title
$AllInputElement | select Attributes
# The $AllInputElements contains all the input elements on the page if we want to find the specific element for the google search box we will need to loop through each input element in the $AllInputElements array and get the attibute we want in this case we're looking for the title attribute.
# And we only want to return the element that has a title equal to Search we can find this out based on the html code on the page.
$Searchbox = $AllInputElement.Where( { $_.Attributes.title -eq 'Search' }, 'first')[0]

# Now for the fun part after finding the element we want to send keyboard input to it. this will allow us to automate the search process
# We can get the list of all special keyboard keys like enter/backspace etc using the Get-SeKeys command
# Now for the fun part after finding the element we want to send keyboard input to it. this will allow us to automate the search process
# We can get the list of all special keyboard keys like enter/backspace etc using the Get-SeKeys command

# Now that we can see all the keys we can send send some keys to the SearchBoxElement
Send-SeKeys -Element $SearchBoxElement -Keys 'Powershell-Selenium'
# Now that we can see all the keys we can send send some keys to the SearchBoxElement
Invoke-SeKeys -Element $Searchbox -Keys 'Powershell-Selenium'

# You can send special key strokes to the SearchBoxElement, you should use the Selenium Keys enum. For example, if we wanted to send an enter key stroke, you could do it like this
Send-SeKeys -Element $SearchBoxElement -Keys ([OpenQA.Selenium.Keys]::Enter)
# You can send special key strokes to the SearchBoxElement, you should use the Selenium Keys enum. For example, if we wanted to send an enter key stroke, you could do it like this
# To view special keys, use Get-SeKeys
Invoke-SeKeys -Element $Searchbox -Keys ([OpenQA.Selenium.Keys]::Enter)

# When working with dynamic websites, it's often necessary to wait awhile for elements to appear on the page. By default, Selenium won't wait and you'll receive $null from Find-SeElement because the element isn�t there yet. There are a couple ways to work around this.
# The first is to use the Find-SeElement cmdlet with the -Wait switch to wait for the existence of an element in the document.
# When using the Find-SeElement with the -Wait please take into account that only 1 element can be returned unlike the without the -Wait switch where multiple elements can be returned.
# When working with dynamic websites, it's often necessary to wait awhile for elements to appear on the page. By default, Selenium won't wait and you'll receive $null from Find-SeElement because the element isn�t there yet. There are a couple ways to work around this.
# The first is to use the Find-SeElement cmdlet with the -Wait switch to wait for the existence of an element in the document.
# When using the Find-SeElement with the -Wait please take into account that only 1 element can be returned unlike the without the -Wait switch where multiple elements can be returned.

# This command will wait for the img elements for 10 seconds and then return it to you or time out if the element wasn't found on.
$LogoImageElement = Find-SeElement -Driver $Driver -Wait -Timeout 10 -Id 'logo'
# This command will wait for the img elements for 10 seconds and then return it to you or time out if the element wasn't found on.
#Note, the value parameter is provided positionally.
$LogoImageElement = Get-SeElement -Timeout 10 -By Id 'logo'

# Once we have the image element we can simulate a mouse click on it using the Invoke-SeClick command.
Invoke-SeClick -Driver $Driver -Element $LogoImageElement
# Once we have the image element we can simulate a mouse click on it using the Invoke-SeClick command.
Invoke-SeClick -Element $LogoImageElement

# Once we are done with the web driver and we finished with all our testing/automation we can release the driver by running the Stop-SeDriver command.
Stop-SeDriver -Driver $Driver
}
# if the driver is not running we will enter the script block in the else section and display a message
else{
Write-Host "The selenium driver was not running." -ForegroundColor Yellow
}
# Once we are done with the web driver and we finished with all our testing/automation we can release the driver by running the Stop-SeDriver command.
Stop-SeDriver
54 changes: 0 additions & 54 deletions Output/Selenium/Examples/DemoSelenium.tests.ps1

This file was deleted.

49 changes: 0 additions & 49 deletions Output/Selenium/Examples/DemoSelenium2.tests.ps1

This file was deleted.

23 changes: 0 additions & 23 deletions Output/Selenium/Examples/TestPSGallery.ps1

This file was deleted.

10 changes: 6 additions & 4 deletions Output/Selenium/Examples/comparison.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public void testClass() throws Exception {
Assert.assertEquals("Wikipedia. the free encyclopedia", driver.getTitle());
}
#>
SeOpen "http://www.wikipedia.org/"
Start-SeDriver -Browser Chrome -StartURL "https://www.wikipedia.org/"
SeShouldHave -Title eq Wikipedia
SeShouldHave 'strong' -By CssSelector -With Text eq 'English' -PassThru | SeClick
SeShouldHave 'strong' -By CssSelector -With Text eq 'English' -PassThru | Invoke-SeClick
SeShouldHave -Title eq 'Wikipedia, the free encyclopedia'

<#
Expand Down Expand Up @@ -52,7 +52,9 @@ public static void main(String[] args) {
}
#>

SeOpen "http://demo.guru99.com/test/newtours/" -In FireFox # or #-in Chrome -in MsEdge -in NewEdge or -in IE
Start-SeDriver -Browser Firefox -StartURL "http://demo.guru99.com/test/newtours/"
SeShouldHave -Title eq "Welcome: Mercury Tours"
SeClose

#Stop opened drivers
Get-SeDriver | Stop-SeDriver

Binary file modified Output/Selenium/Selenium.psm1
Binary file not shown.
Binary file modified Output/Selenium/assemblies/IEDriverServer.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion Output/Selenium/assemblies/IEDriverServer.exe.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
A1E26B0E8CB5F8DB1CD784BAC71BBF540485D81E697293B0B4586E25A31A8187
51053574E3BA3AB5D9F47E13EC0E9961AD6C9C9978DC851BE71C0F86A272C74B
Binary file modified Output/Selenium/assemblies/chromedriver.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion Output/Selenium/assemblies/chromedriver.exe.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0986FA1D2B07F3C755B84BC50D8115A09F246BF2D30BC1B850B957BC394FAD53
5BFEADAEB1182DC068B60377BA34C010317D6AE19DA4934A221B2B1F3A050889
Binary file modified Output/Selenium/assemblies/geckodriver.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion Output/Selenium/assemblies/geckodriver.exe.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
255C9D3571C86841213F49B26D176A6AD440BE8C720E3C2D9226076ADF4F603D
FAED02EC5B0D6246856843D10EE020CB5121B8261AC939BE761130F21A73D3EE
Binary file modified Output/Selenium/assemblies/linux/geckodriver
Binary file not shown.
2 changes: 1 addition & 1 deletion Output/Selenium/assemblies/linux/geckodriver.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6590E3B9D9BF292C8DF50B6DF5BCF8A5191D999F9E48F68AA2055EB5746B2C05
0B2C9B9791925DCEA2981CBDFAB8274FB4668BF65D6A57C2257E8B57757C394A
Binary file modified Output/Selenium/assemblies/macos/chromedriver
Binary file not shown.
2 changes: 1 addition & 1 deletion Output/Selenium/assemblies/macos/chromedriver.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
F24498EAF30B191CB79A55903457A8799E2695657C889AF4824390BF2D379F30
9793D91D3448E35061606F37F1EB3EECC7B492CF159E6A318395445FB75B46EC
Binary file modified Output/Selenium/assemblies/macos/geckodriver
Binary file not shown.
2 changes: 1 addition & 1 deletion Output/Selenium/assemblies/macos/geckodriver.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
D62C2178377ADDEB1BB860426B2C9B10B68D2EEABF0C521529A4A6A7B1E208C4
AA2FCE6B96183C9D8FD0AA125F87557FCCEC60301CF7ADD1578B0DA59355AD8B
Binary file modified Output/Selenium/assemblies/msedgedriver.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion Output/Selenium/assemblies/msedgedriver.exe.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
509FFD6D321EF78C8319E68B89807D2437D8DB1718000FE2BB7ECACB1529730D
A6EB02FF3EF75079A647F20BD0B6B563648BC4C8563443229C65671AB0BBB6CD
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy