Jump to content

Recommended Posts

Posted

How to know the handle of first create tab in webdriver?

If my code is below:
ย 

#include "wd_core.au3"
#include "wd_helper.au3"

Local $sDesiredCapabilities, $sSession
SetupGecko()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)

;=========================================================================

$sTab1 = _WD_NewTab($sSession)
_WD_Navigate($sSession, "https://www.xzy.xzy/")
$sTab2 = _WD_NewTab($sSession)
_WD_Navigate($sSession, "https://www.abc.abc/")

_WD_Window($sSession, 'Switch', '{"handle":"' & $sTab1 & '"}')

;=========================================================================

Func SetupGecko()
    _WD_Option('Driver', 'geckodriver.exe')
    _WD_Option('Port', 4444)
    _WD_Option('DriverParams', '--log trace')
    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}'
EndFunc


There will be 3 tab
first tab is empty
second tab is xyz
third tab is abc

it will first open firefox and create first tab which is empty
then
it will create second tab and navigate to xyz
then
it will create third tab and navigate to abc
then
it will attach back to second tab which is xyz

my question is:
i know the handle of the second and third tab from the handle returned when doing _WD_NewTab

but how can I switch back to the first empty tab?

Thank You

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

@SOLVE-SMART
Sorry for creating new topic again

Posted (edited)
6 hours ago, HezzelQuartz said:

Sorry for creating new topic again

No, it's good to separate topics in new threads ๐Ÿ‘ .

-----------

An example on handling multiple tabs can be found here (autoit-webdriver-boilerplate).

  1. Read section: README > Features > Branches > "multiple-browser-tabs"
  2. Have a deeper look at functionย _Steps()ย and the functions _NextTab(), _PreviousTab() and _CloseTab.

I believe this should be helpful ๐Ÿค .

Best regards
Sven

Edited by SOLVE-SMART

==> AutoIt related: ๐Ÿ”— GitHub, ๐Ÿ”— Discord Server

Spoiler

๐ŸŒย Au3Forums

๐ŸŽฒ AutoIt (en) Cheat Sheet

๐Ÿ“Š AutoIt limits/defaults

๐Ÿ’Ž Code Katas: [...] (comming soon)

๐ŸŽญ Collection of GitHub users with AutoIt projects

๐Ÿžย False-Positives

๐Ÿ”ฎย Me on GitHub

๐Ÿ’ฌย Opinion about new forum sub category

๐Ÿ“‘ย UDF wiki list

โœ‚ย VSCode-AutoItSnippets

๐Ÿ“‘ย WebDriver FAQs

๐Ÿ‘จโ€๐Ÿซย WebDriver Tutorial (coming soon)

Posted (edited)
1 hour ago, SOLVE-SMART said:

No, it's good to separate topics in new threads ๐Ÿ‘ .

-----------

An example on handling multiple tabs can be found here.

1. Read section: README > Features > Branches > "multiple-browser-tabs"

2. Have a deeper look at functionย _Steps()ย and the functions _NextTab(), _PreviousTab() and _CloseTab.

I believe this should be helpful ๐Ÿค .

Best regards
Sven


@SOLVE-SMART
Sorry, is that newer webdriver udf?
Should I change udf?

I actually confused
could you give me simple example or clue how to use that udf?

Thank You

Edited by HezzelQuartz
  • Solution
Posted (edited)

No it is not a different one. It's a wrapper around the great work / UDF of @Danp2ย (and @mLipok).

As described in the description (README):

Quote

The project "autoit-webdriver-boilerplate" can be used as quick entry point for the awesome au3WebDriver project by @Danp2 (and @mlipok). The intention is, give people a easy start with WebDriver for AutoIt.

I simply wanted to show you an example on how to deal with multiple tabs, because this topic was asked before and I added such a example (as separate git branch) on my repository/project. So you can either read through the project and give it a try or you stick to the examples of the wd_demo.au3 of the origin au3WebDriver project. All is fine.

In the mentioned functions _NextTab(), _PreviousTab() and _CloseTab you can see one approach to handle browser tabs. In the _Steps() function you see the usage of these functions. I do have video tutorials online for the autoit-webdriver-boilerplate (a crash course), but in german. So I guess it's not that helpful.

--------------------

My suggestion: Concentrate on your current task (handling browser tabs, as you asked in this thread). Then, if you want, walk through my boilerplate project and give it a try. If it's not documented good enough, please let me know. I am grateful for improvement ideas ๐Ÿค .

Best regards
Sven

Edited by SOLVE-SMART

==> AutoIt related: ๐Ÿ”— GitHub, ๐Ÿ”— Discord Server

Spoiler

๐ŸŒย Au3Forums

๐ŸŽฒ AutoIt (en) Cheat Sheet

๐Ÿ“Š AutoIt limits/defaults

๐Ÿ’Ž Code Katas: [...] (comming soon)

๐ŸŽญ Collection of GitHub users with AutoIt projects

๐Ÿžย False-Positives

๐Ÿ”ฎย Me on GitHub

๐Ÿ’ฌย Opinion about new forum sub category

๐Ÿ“‘ย UDF wiki list

โœ‚ย VSCode-AutoItSnippets

๐Ÿ“‘ย WebDriver FAQs

๐Ÿ‘จโ€๐Ÿซย WebDriver Tutorial (coming soon)

Posted
1 hour ago, SOLVE-SMART said:

No it is not a different one. It's a wrapper around the great work / UDF of @Danp2ย (and @mLipok).

As described in the description (README):

I simply wanted to show you an example on how to deal with multiple tabs, because this topic was asked before and I added such a example (as separate git branch) on my repository/project. So you can either read through the project and give it a try or you stick to the examples of the wd_demo.au3 of the origin au3WebDriver project. All is fine.

In the mentioned functions _NextTab(), _PreviousTab() and _CloseTab you can see one approach to handle browser tabs. In the _Steps() function you see the usage of these functions. I do have video tutorials online for the autoit-webdriver-boilerplate (a crash course), but in german. So I guess it's not that helpful.

--------------------

My suggestion: Concentrate on your current task (handling browser tabs, as you asked in this thread). Then, if you want, walk through my boilerplate project and give it a try. If it's not documented good enough, please let me know. I am grateful for improvement ideas ๐Ÿค .

Best regards
Sven


Now, I Understand

Thank You

Really Helpful for me

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
  • Recently Browsing   0 members

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