1

Here is the PS code

$url="http://site.example"
$ie = New-Object -com internetexplorer.application
$ie.visible = $true
$ie.navigate($url)

but I want to click on button (Play Now)

Here is the HTML code

<div data-a-target="lb-core-button-label-text" class="lb-flex-grow-0">Play Now</div>

any suggesting please

2

1 Answer 1

2

Sure, you can use Powershell to click things on a web page, but you have to explicitly tell it to, using the target element and method.

For example:

# Get all the needed elements
# Scrape the page
$Pwpush = Invoke-WebRequest -Uri 'https://pwpush.com'
$Pwpush.Content
$Pwpush.AllElements
$Pwpush.Forms
$Pwpush.InputFields
$Pwpush.AllElements.FindById('password_payload')
$Pwpush.AllElements.FindByName('commit')


# Full run using the target elements
$password = '1234'
$loginUrl = 'https://pwpush.com'

$ie = New-Object -com internetexplorer.application
$ie.visible = $true
$ie.navigate($loginUrl)

while ($ie.Busy -eq $true) { Start-Sleep -Seconds 1 }

($ie.document.getElementById('password_payload') | 
select -first 1).value = $password
Start-Sleep -Seconds 1 

$ie.Document.getElementsByName('commit').Item().Click();
Start-Sleep -Seconds 1 

Of course, those pauses are not always necessary, but I have them there just as a delay to see what is happening and to make sure render has completed before taking the next action(s)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.