Jump to content

WebDriver UDF (W3C compliant version) - 2024/02/19


Danp2
 Share

Recommended Posts

Hi Danp2,

Sorry....I should have done that -- it was such a brief example, I thought my explanation covered it.

Below is the snippet of code I am trying:

_WD_Navigate($sSession, "https://www.fedex.com/servlet/InvoiceServlet?link=4&jsp_name=adjustment&orig_country=US&language=english")

This code above navigates to a generic FedEx page -- not the intended page (undesired_result.png) that I can navigate to manually (desired_result.png).

Second attempt is to go to the parent page and click on a link vs trying to directly navigate (above example):

_WD_Navigate($sSession, "https://www.fedex.com/en-us/customer-support/claims.html")
$sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div[2]/div[4]/div[2]/div[1]/div[1]/div/div[1]/div[2]/div/a")
_WD_ElementAction($sSession, $sLink, 'click')

Both attempts give the same result.

Please see the attached images.

desired_result.png

undesired_result.png

Edited by NSearch
Link to comment
Share on other sites

Thanks for the reply Danp2.

 

Is it working for you when you initially navigate to the main page?

 

Neither of these work for me.

_WD_Navigate($sSession, "https://www.fedex.com")
_WD_Navigate($sSession, "https://www.fedex.com/servlet/InvoiceServlet?link=4&jsp_name=adjustment&orig_country=US&language=english")
_WD_Navigate($sSession, "https://www.fedex.com")
_WD_Navigate($sSession, "https://www.fedex.com/en-us/customer-support/claims.html")
$sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div[2]/div[4]/div[2]/div[1]/div[1]/div/div[1]/div[2]/div/a")
_WD_ElementAction($sSession, $sLink, 'click')

 

Link to comment
Share on other sites

44 minutes ago, NSearch said:

Do you have any suggestions on what I should do. Would you share what you are using for $sDesiredCapabilities?

Not really. DesiredCapabilities are very basic ==

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

 

Link to comment
Share on other sites

I agree with @Danp2 that it may have something to do with the cookies. I included my default user data directory in the capabilities and it worked OK. One thing you must remember is that you must close all existing Chrome browser sessions before running this script because every chromedriver session needs a unique user data directory.

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

Local $sDesiredCapabilities

$_WD_DEBUG = $_WD_Debug_Info ;None
$_WD_ERROR_MSGBOX = False
SetupChrome()
_WD_Startup()

$sSession = _WD_CreateSession($sDesiredCapabilities)
Sleep(1000)
_WD_LoadWait($sSession)

_WD_Navigate($sSession, "https://www.fedex.com/servlet/InvoiceServlet?link=4&jsp_name=adjustment&orig_country=US&language=english")

Func SetupChrome()
    If Not FileExists("chromedriver.exe") Then
        MsgBox(4096, "", "ChromeDriver is not available in the sript directory!")
        Exit
    EndIf
    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('DriverParams', '--log-path=chrome.log')
    _WD_Option('Port', 9515)

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", ' & _
        '"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, ' & _
        '"prefs": {"credentials_enable_service": false}, ' & _
        '"args": ["start-maximized", "user-data-dir=C:\\Users\\(put your user name here)\\AppData\\Local\\Google\\Chrome\\User Data", "profile-directory=Default"] }}}}'
EndFunc

 

Link to comment
Share on other sites

I get the same result (We're sorry, we can't process your request at this time), with your code, in Chrome.

Is there a function that will delete all cookies in Firefox?

Edit: found it: _WD_Cookies($sSession,'delete')

I added that after the session is created and I still get the same result.

Edited by NSearch
Link to comment
Share on other sites

Thanks @CYCho

I am now able to get back to the page, but there's another problem -- will you please check to see if you're having the same result?

When I reach https://www.fedex.com/servlet/InvoiceServlet?link=4&jsp_name=adjustment&orig_country=US&language=english I click on FedEx Ground, "I received a FedEx invoice(Electronic or paper), then "Make a new request". When I do, I get an error: "Access to www.fedex.com was denied"

$sElement_Ground_Radio = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr/td[3]/table[2]/tbody/tr/td[2]/form/table/tbody/tr/td/table/tbody/tr/td[2]/table[1]/tbody/tr[2]/td[1]/input")
_WD_ElementAction($sSession, $sElement_Ground_Radio, 'click')

$sElement_Pay_Radio = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr/td[3]/table[2]/tbody/tr/td[2]/form/table/tbody/tr/td/table/tbody/tr/td[2]/table[2]/tbody/tr[1]/td[3]/input")
_WD_ElementAction($sSession, $sElement_Pay_Radio, 'click')

$sElement_Submit_Radio = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr/td[3]/table[2]/tbody/tr/td[2]/form/table/tbody/tr/td/table/tbody/tr/td[2]/table[3]/tbody/tr[1]/td/input")
_WD_ElementAction($sSession, $sElement_Submit_Radio, 'click')

 

Link to comment
Share on other sites

On 1/11/2020 at 6:05 PM, CYCho said:

It seems that the web site detects my geolocation and denies my access to these pages, so I can't go any further. They have a Korean page, which is quite different from the US one. By any chance, wouldn't these pages require a log in?

Hi CYCho,

The pages do not require logging in.

Do you know how to create an incognito session?

Link to comment
Share on other sites

  • Danp2 changed the title to WebDriver UDF (W3C compliant version) - 2024/02/19
  • 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...