11Function Visibility {
2- <#
3- The 'Visibility' Parameter sets the visibility of the Activity.
4- This statement can be included within the fixture or executed within the Param Block, similar to 'Area' and 'Contribution Area'.
5- Multiple statements aren't allowed within the Fixture.
6-
7- . PARAMETER Name
8- The Visibility Name: Values can be: 'Everyone','MVP Community' & 'Microsoft'.
9-
10- . EXAMPLE
11- In the example, 'Visibility' is set within the Fixture:
12-
13- MVPActivity "Test" {
2+ <#
3+ The 'Visibility' Parameter sets the visibility of the Activity.
4+ This statement can be included within the fixture or executed within the Param Block, similar to 'Area' and 'Contribution Area'.
5+ Multiple statements aren't allowed within the Fixture.
146
15- # Let's set the Area and the Contribution Area
16- Area 'Article'
17- Visibility 'Microsoft'
18-
19- # We can set the mandatory parameters
20- Value "Number of Articles" 1
21- Value Title "Test Entry"
22- Value Date "30/11/2020"
23-
24- }
25-
26- . EXAMPLE
27- In the example, 'Visibility' is set within the param block:
28-
29- MVPActivity "Test" {
30- param($Visibility)
7+ . PARAMETER Name
8+ The Visibility Name: Values can be: 'Everyone','MVP Community' & 'Microsoft'.
319
32- # Let's set the Area and the Contribution Area
33- Area 'Article'
34-
35- # We can set the mandatory parameters
36- Value "Number of Articles" 1
37- Value Title "Test Entry"
38- Value Date "30/11/2020"
39-
40- }
41-
42- . SYNOPSIS
43- Set's the Visibility of the entry.
44-
45- #>
10+ . EXAMPLE
11+ In the example, 'Visibility' is set within the Fixture:
12+
13+ MVPActivity "Test" {
14+
15+ # Let's set the Area and the Contribution Area
16+ Area 'Article'
17+ Visibility 'Microsoft'
18+
19+ # We can set the mandatory parameters
20+ Value "Number of Articles" 1
21+ Value Title "Test Entry"
22+ Value Date "30/11/2020"
23+
24+ }
25+
26+ . EXAMPLE
27+ In the example, 'Visibility' is set within the param block:
28+
29+ MVPActivity "Test" {
30+ param($Visibility)
31+
32+ # Let's set the Area and the Contribution Area
33+ Area 'Article'
34+
35+ # We can set the mandatory parameters
36+ Value "Number of Articles" 1
37+ Value Title "Test Entry"
38+ Value Date "30/11/2020"
39+
40+ }
41+
42+ . SYNOPSIS
43+ Set's the Visibility of the entry.
44+
45+ #>
4646 [CmdletBinding ()]
4747 param (
4848 [Parameter (Mandatory )]
4949 [String ]
5050 [ValidateSet (' Everyone' , ' MVP Community' , ' Microsoft' )]
5151 $Name
5252 )
53-
5453 # Test if the Driver is active. If not throw a terminating error.
5554 Test-SEDriver
5655 # Test the Callstack.
5756 Test-CallStack $PSCmdlet.MyInvocation.MyCommand.Name
5857
59- # Locate the Visability Element.
60- $VisibilityElement = Find-SeElement - Driver ($Global :MVPDriver ) - By XPath - Selection $LocalizedData.ElementVisibilityBoxXPath
61- if ($null -eq $VisibilityElement ) { return }
58+ Write-Verbose " [Visibility()] Invoked. Parameter `$ Name: $Name "
6259
63- # Match the Name of the Element. If the name is the same, skip!
64- if ($Name -eq $VisibilityElement.Text ) { return }
65-
66- # Select the Element and Select the Correct Item
67- Invoke-SeClick - Element $VisibilityElement
6860 # Locate the ListItem Permission
6961 $PermissionsParams = @ {
7062 Driver = $Global :MVPDriver
7163 By = ' XPath'
7264 Selection = $LocalizedData.VisibilityListItem -f $Name
7365 }
74- $PermissionElement = Find-SeElement @PermissionsParams
7566
76- # Select the DropDown Item
77- Invoke-SeClick - Element $PermissionElement
78-
67+ $sleepTimer = 250
68+
69+ ttry {
70+
71+ # Locate the Visibility Element.
72+ $VisibilityElement = Find-SeElement - Driver ($Global :MVPDriver ) - By XPath - Selection $LocalizedData.ElementVisibilityBoxXPath
73+
74+ Write-Verbose " [Visibility()] `$ VisibilityElement isNull: $ ( $null -eq $VisibilityElement ) "
75+ Write-Verbose " [Visibility()] `$ VisibilityElement.Text : $ ( $VisibilityElement.Text ) "
76+
77+ if ($null -eq $VisibilityElement ) { return }
78+ if ($Name -eq $VisibilityElement.Text ) { return }
79+
80+ Write-Verbose " [Visibility()] Selecting VisibilityElement"
81+
82+ # Select the Element and Select the Correct Item
83+ Invoke-SeClick - Element $VisibilityElement
84+
85+ Start-Sleep - Milliseconds $sleepTimer
86+
87+ Write-Verbose " [Visibility()] Finding VisibilityListItem:"
88+ $PermissionElement = Find-SeElement @PermissionsParams
89+
90+ Write-Verbose " [Visibility()] `$ VisibilityListItem isNull: $ ( $null -eq $PermissionElement ) "
91+
92+ Start-Sleep - Milliseconds $sleepTimer
93+ # Select the DropDown Item
94+
95+ Write-Verbose " [Visibility()] Selecting Visibility From Dropdown : $Name "
96+ Invoke-SeClick - Element $PermissionElement
97+
98+ } - catch {
99+
100+ Write-Warning " [ERROR]. Failed to set Visibility. Retrying:"
101+ $SleepTimer += 100
102+
103+ } - RetryLimit 5
104+
79105}
0 commit comments