Jump to content

webdriver click over pupup ?


faustf
 Share

Recommended Posts

i try to do that with this  part of code

but  not  click over  how  is possible click over popup ?

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5
 Author:         faustf

 Script Function:
    lillirobot

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
; Script Start - Add your code below here
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <Array.au3>
#include "wd_core.au3"
#include "wd_helper.au3"
#include <GuiComboBoxEx.au3>


Global $sDesiredCapabilities,$sSession

Global $sGMail='xxxxxxxxxxxxx'
Global $sGPass='xxxxxx'
SetupGecko()

_WD_Startup()

If @error <> $_WD_ERROR_Success Then
    Exit -1
EndIf

$sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_Navigate($sSession, "https://www.instagram.com/?hl=it")

_WD_Timeouts($sSession, '{"pageLoad":3000}')

Sleep (2000)
;<input size="45" name="all" type="TEXT">
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='username']")

If @error = $_WD_ERROR_Success Then
    _WD_ElementAction($sSession, $sElement, 'click')
    _WD_ElementAction($sSession, $sElement, 'value', $sGMail)
EndIf

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='password']")

If @error = $_WD_ERROR_Success Then
    _WD_ElementAction($sSession, $sElement, 'click')
    _WD_ElementAction($sSession, $sElement, 'value', $sGPass)
EndIf

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@type='submit']")

If @error = $_WD_ERROR_Success Then
    _WD_ElementAction($sSession, $sElement, 'click')
EndIf

 _WD_LoadWait($sSession)

While 1
Local $sLHtmlSource=_WD_GetSource($sSession)
if StringInStr ($sLHtmlSource,"Vuoi salvare le informazioni di accesso?") Then
    ExitLoop
EndIf
WEnd

Local $sLHtmlSource=_WD_GetSource($sSession)
ConsoleWrite($sLHtmlSource&@CRLF)


$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@type='button']")

If @error = $_WD_ERROR_Success Then
    _WD_ElementAction($sSession, $sElement, 'click')
EndIf

MsgBox(0,'','sono qui')

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@tabindex='0']")

If @error = $_WD_ERROR_Success Then
    _WD_ElementAction($sSession, $sElement, 'click')
EndIf


;_WD_DeleteSession($sSession)
;_WD_Shutdown()


Func SetupGecko()
_WD_Option('Driver', 'geckodriver.exe')
_WD_Option('DriverParams', '--log trace')
_WD_Option('Port', 4444)

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}'
EndFunc

 

Link to comment
Share on other sites

Some general feedback on your script --

  • _WD_Timeouts($sSession, '{"pageLoad":3000}')

Not sure why you need this, but should likely be placed before the navigation to have the effect you desire.

  • Sleep (2000)

Shouldn't be needed. Use this instead --

_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='username']")
  • _WD_ElementAction($sSession, $sElement, 'click')

Don't see why these would be necessary. Did you try without the click?

  • While... WEnd

Drop this whole thing and just use a single call to _WD_WaitElement looking for the desired xpath. If found, then use _WD_FindElement and _WD_ElementAction to locate and click the element

Link to comment
Share on other sites

2 hours ago, faustf said:

i try to add your fixed  but not  work ,without  sleep run fast without  click not insert in inputbox  a  mail and pass

(OT : just a friendly suggestion)

I really do not want to be intimidating, but PLEASE try https://www.deepl.com/translate . The automatic translation should be a lot easier to understand compared to your Yoda-Speak ;).

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

@faustf You've been around here long enough to know better then to tell us something like "doesn't work" without providing further details. :naughty:

 I've tried these suggestions with your original code and they worked for me. However, I'm not going to spoon feed you the solution. So show us the revised code and also the Scite console output so that we can see where you went wrong.

Link to comment
Share on other sites

Func SetupGecko()
_WD_Option('Driver', '../Required/geckodriver.exe')
_WD_Option('DriverParams', '--marionette-port 2828')
_WD_Option('Port', 4444)

$sDesiredCapabilities = '{"capabilities":{"alwaysMatch": {"moz:firefoxOptions": {"args": ["-profile", "C:/Users/Admin/AppData/Roaming/Mozilla/Firefox/Profiles/(whatever)"],"log": {"level": "trace"}}}}}'
EndFunc

This info was taken from the Wiki FAQ's page, which is suppose to utilize an existing user profile. It works fine for users with one firefox profile, but what about those with multiple profiles?

I have 2 different sessions in use - A and B.

If I close / Alt+F4 session A and then B, the next time I run the wd_demo.au3 DemoNav, session B will open up.

And vice versa; if I close / Alt+F4 session B and then A, the next time I run the wd_demo.au3 DemoNav, session A will open up.

 

Is there a way to make it stick with one profile specifically for users that have more than 2 profiles?

Edited by Purity8
Link to comment
Share on other sites

@Purity8 Sorry, but I don't understand your explanation of the problem. If you are supplying a profile in the Capacities string, then I don't understand how the wrong profile could be loading. Is this all occurring in instances launched via geckodriver or are you manually launching firefox in some instance. Please clarify exactly what steps you are performing.

P.S. It's kind of odd that you "hijacked" this thread, which is on a completely unrelated issue, instead of starting your own. 🙄

Link to comment
Share on other sites

3 minutes ago, Danp2 said:

P.S. It's kind of odd that you "hijacked" this thread, which is on a completely unrelated issue, instead of starting your own. 🙄

My apologies, I have a habit of reading the forums & forget to check where I'm browsing. Or maybe its that I'm seeing the user @faustf post in almost everywhere & I'm getting lost somehow...

I thought I was already in:WebDriver UDF (W3C compliant version) - 08/28/2020 - page 39

I'll move (back) over there for more assistance.

Link to comment
Share on other sites

hi  i dont  want a  spoon feed  , i ask only how  is possible click over popup  this is  a code  with correction and  this is  a how  work

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5
 Author:         faustf

 Script Function:
    lillirobot

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
; Script Start - Add your code below here
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <Array.au3>
#include "wd_core.au3"
#include "wd_helper.au3"
#include <GuiComboBoxEx.au3>


Global $sDesiredCapabilities,$sSession

Global $sGMail='xxxxxxxxxxxx'
Global $sGPass='xxxxxxxxxxxxxx'
SetupGecko()

_WD_Startup()

If @error <> $_WD_ERROR_Success Then
    Exit -1
EndIf


$sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_Timeouts($sSession, '{"pageLoad":3000}')

_WD_Navigate($sSession, "https://www.instagram.com/?hl=it")



;Sleep (2000)
;<input size="45" name="all" type="TEXT">
$sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='username']")

If @error = $_WD_ERROR_Success Then
    ;_WD_ElementAction($sSession, $sElement, 'click')
    _WD_ElementAction($sSession, $sElement, 'value', $sGMail)
EndIf

$sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='password']")

If @error = $_WD_ERROR_Success Then
    ;_WD_ElementAction($sSession, $sElement, 'click')
    _WD_ElementAction($sSession, $sElement, 'value', $sGPass)
EndIf

$sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@type='submit']")

If @error = $_WD_ERROR_Success Then
    _WD_ElementAction($sSession, $sElement, 'click')
EndIf

 _WD_LoadWait($sSession)
#cs
While 1
Local $sLHtmlSource=_WD_GetSource($sSession)
if StringInStr ($sLHtmlSource,"Vuoi salvare le informazioni di accesso?") Then
    ExitLoop
EndIf
WEnd
#ce
Local $sLHtmlSource=_WD_GetSource($sSession)
;ConsoleWrite($sLHtmlSource&@CRLF)


$sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@type='button']")

If @error = $_WD_ERROR_Success Then
    _WD_ElementAction($sSession, $sElement, 'click')
EndIf

MsgBox(0,'','sono qui')

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@tabindex='0']")

If @error = $_WD_ERROR_Success Then
    _WD_ElementAction($sSession, $sElement, 'click')
EndIf


;_WD_DeleteSession($sSession)
;_WD_Shutdown()


Func SetupGecko()
_WD_Option('Driver', 'geckodriver.exe')
_WD_Option('DriverParams', '--log trace')
_WD_Option('Port', 4444)

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}'
EndFunc

thankz at  all

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...