You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
Copy file name to clipboardExpand all lines: Output/Selenium/ChangeLog.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
#4.0.0 (Unreleased)
2
2
3
3
4
-
# 4.0.0-beta-1 (Prerelease)
4
+
# 4.0.0-preview1 (Prerelease)
5
5
Note: V4 have an enormous amount of breakchanges. Most of the cmdlet have been rewriten in a way or another.
6
6
7
7
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.
This is an example script that will show you how to use the Selenium driver to preform a simple google search.
6
-
Using this example script you will learn the basic usage of the Selenium powershell module.
7
-
Each comment line will explain the line that will come after it so you can follow it in a step by step fashion.
8
-
#>
9
-
10
1
# The line below will Import-Module Selenium if it fails it will display the installation command and stop the script.
11
-
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}
# 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.
17
-
if($Driver){
18
-
# Now that we verified that the driver is running we can start doing cool things with it.
19
7
20
-
# 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
21
-
# 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.
# 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.
25
-
# We can find elements using different ways like the element id or the Name/ClassName/TagName and a few other ways.
26
-
# In the below code we're going to show you a few ways to solve this problem.
9
+
#Getting the Search box
27
10
28
-
<# This is the HTML code of the search box
11
+
<# This is the HTML code of the search box, found using the browser developer tools
# 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
# 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
18
+
#The Single parameter will write an error if there's not 1 element.
19
+
$Searchbox=Get-SeElement-By Name -value q -Single
37
20
38
-
# This line will get us all elements with the input TagName also known as <input>
# We can also use the class name gLFyf to find the google search box.
22
+
$Searchbox=Get-SeElement-ClassName 'gLFyf'
40
23
41
-
# 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.
42
-
# 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.
# This line will get us all elements with the input TagName also known as <input>
25
+
#The -All parameter (optional) also includes hidden elements.
26
+
# The -Attributes parameter will load the specified attribute in the result and make them available through an Attributes property
27
+
$AllInputElement=Get-SeElement-By TagName -Value input -All -Attributes title
28
+
$AllInputElement| select Attributes
29
+
# 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.
30
+
# 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.
# 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
# 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
# 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.
55
-
# The first is to use the Find-SeElement cmdlet with the -Wait switch to wait for the existence of an element in the document.
56
-
# 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.
43
+
# 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.
44
+
# The first is to use the Find-SeElement cmdlet with the -Wait switch to wait for the existence of an element in the document.
45
+
# 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.
57
46
58
-
# 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.
0 commit comments