Jump to content

WebDriver UDF (W3C compliant version) - 2024/09/21


Danp2
 Share

Recommended Posts

If I use the chrome driver and click on a link in my script for a website, and that link creates another tab, how can I attach to the new tab that was created using the chrome driver???

Also, is there any documentation for the chrome driver methods??? Like

  • _WD_CreateSession($sDesiredCapabilities='{}')
  • _WD_DeleteSession($sSession)
  • _WD_Status()
  • _WD_Timeouts($sSession, $sTimeouts = '')
  • _WD_Navigate($sSession, $sURL)
  • _WD_Action($sSession, $sCommand)
  • _WD_Window($sSession, $sCommand, $sOption = '')

etc... I have found no documentation for these methods??? Can anyone help???

Link to comment
Share on other sites

In my script here for Chrome...

Sleep(3000)
$sReportOpt = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//a[@class='menu-icon-report']")
_WD_ElementAction($sSession, $sReportOpt, 'click')

My _WD_ElementAction creates a new tab... how do I attach to that new tab that was created when this method is executed??? And then when I am done with this tab, how do I close it???

 

Link to comment
Share on other sites

3 minutes ago, lponthepc said:

In my script here for Chrome...

Sleep(3000)
$sReportOpt = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//a[@class='menu-icon-report']")
_WD_ElementAction($sSession, $sReportOpt, 'click')

My _WD_ElementAction creates a new tab... how do I attach to that new tab that was created when this method is executed??? And then when I am done with this tab, how do I close it??? 

I saw the _WD_Attach examples... but that was for "URL's" ... this new tab was created when I click on a link in the website... so this may be different I'm thinking...

 

 

 

Link to comment
Share on other sites

In fact, this problem is very meaningful. Without knowing the specific return value, the next step can be made by judging the possible shape of the return value, which can make the code more robust, stable and reliable.

Response={"value":null}
Response={"value":""}
Response={"value":[]}
Response={"value":{}}
Response={"value":True}
Response={"value":1000}
Response={"value":["TX0058_2","TX0058_5"]}
Response={"value":{"TX0058_2":"A","TX0058_5":"D"]}

As shown above.
If the value 'Response' I get may be one of the above results,
I want to further resolve the value of '[value]',
what functions or methods can I use to distinguish them?

 

Link to comment
Share on other sites

In addition, there are some questions :

1, how to switch to a specified tab?

2, how to close one of several tabs?

20190722185922.png.a8c813b764f3e8d1d52d4500251436a9.png

Open the new tab. I know I can use _ WD_NewTab..

But I haven't figured out which function to use in the above question and how to use it.

Edited by Letraindusoir
Link to comment
Share on other sites

5 hours ago, lponthepc said:

how can I attach to the new tab that was created

39 minutes ago, Letraindusoir said:

how to switch to a specified tab?

_WD_Attach is the function you seek. It handles locating and then switching to the designated tab. There are examples of using it in wd_demo. 😉

 

Link to comment
Share on other sites

5 hours ago, lponthepc said:

Also, is there any documentation for the chrome driver methods???  I have found no documentation for these methods??? Can anyone help???

Again, I would refer you to wd_demo for examples of using most of the available functions. Looking at the UDF's source code, you will find links in many of the functions that take you to the appropriate section of the W3C specs, which is the ultimate reference for anything webdriver related. For example --

; #FUNCTION# ====================================================================================================================
; Name ..........: _WD_CreateSession
; Description ...: Request new session from web driver
; Syntax ........: _WD_CreateSession([$sDesiredCapabilities = '{}'])
; Parameters ....: $sDesiredCapabilities- [optional] a string value. Default is '{}'.
; Return values .: Success      - Session ID to be used in future requests to web driver session
;                  Failure      - Empty string
;                  @ERROR       - $_WD_ERROR_Success
;                               - $_WD_ERROR_Exception
;                  @EXTENDED    - WinHTTP status code
; Author ........: Dan Pollak
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........: https://www.w3.org/TR/webdriver#new-session
; Example .......: No
; ===============================================================================================================================

See the link entry near the bottom. Going there will take you to the New Session entry in the webdriver specs.

Link to comment
Share on other sites

5 hours ago, lponthepc said:

I saw the _WD_Attach examples... but that was for "URL's" ... this new tab was created when I click on a link in the website... so this may be different I'm thinking...

To use _WD_Attach, you'll need to know something about the new tab. You options are to use title, URL, or HTML. This is documented in the function header.

Link to comment
Share on other sites

1 hour ago, Letraindusoir said:

I went to send a post, and no one actually cared about the problem itself.

I believe they had difficulty understanding your situation because you only gave raw JSON without any context or code.

Apparently, you didn't bother to locate the example I previously mentioned. Care to explain why?

Link to comment
Share on other sites

@trangtrau The short answer is

$_WD_ERROR_MSGBOX = False

However, you shouldn't be getting this error box on a return value of Success. I'll have to take another look at this, but I thought this issue was recently fixed. Please make sure that you are running the latest version of the UDF (currently 0.1.0.20)

Link to comment
Share on other sites

3 minutes ago, Danp2 said:

@trangtrau The short answer is

$_WD_ERROR_MSGBOX = False

However, you shouldn't be getting this error box on a return value of Success. I'll have to take another look at this, but I thought this issue was recently fixed. Please make sure that you are running the latest version of the UDF (currently 0.1.0.20)

image.png.6d794e7dec969790ad255e2dc68e14ef.png

This is newest vesion, Thank you, i'll try again

Link to comment
Share on other sites

2 hours ago, Danp2 said:

I believe they had difficulty understanding your situation because you only gave raw JSON without any context or code.

Apparently, you didn't bother to locate the example I previously mentioned. Care to explain why? 

I'm sorry, I'm not very good at English, so the search results are not easy to screen out useful ones.:mad2:

Link to comment
Share on other sites

  • Danp2 changed the title to WebDriver UDF (W3C compliant version) - 2024/09/21
  • Melba23 pinned this topic

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

×
×
  • Create New...