Jump to content

Recommended Posts

Posted
  On 3/29/2019 at 3:39 PM, Hamburgo said:

I posted the command that I am figured out to send keystrokes. Do you know a better way ?

Expand  

That command is designed to update the value of an element. YMMV when used in the manner you describe.

  On 3/29/2019 at 3:39 PM, Hamburgo said:

Only ctrl+f will not do his job and will not open the search-field of FireFox. Do you know a reason ?

Expand  

Probably because the keystroke is being handled at the element level rather than the browser level. Depending on your goal, either of the following should work --

  • Use _WD_ExecuteScript to execute the javascript command find(), ie:
    $result = _WD_ExecuteScript($sSessionID, "return find('yourstringhere')")
  • Send the keystroke to the browser rather than the element. Now were back to the advanced feature with little documentation. Here's a hint if you choose to go this route --
    https://github.com/nicholaswmin/webdriver-actions
Posted

@Danp2 Do you know how can I search a-tag by href='SearchString' if the SearchString has inside UTF8-Characters like the german once ?

for example:

$sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='#löhne_&_gehälter']")

$sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='#l%C3%B6hne_&_geh%C3%A4lter']")

The _WD_FindElement-Function did not find any of this two strings.

Posted (edited)

Good evening Danp2, 

First, I wanted to thank you and the team for creating this awesome tool. I feel like I missed the party but glad I am outside knocking on the door to get in. Second, once I get this script working you and the team have helped save 10 high school teachers about 100+ hours worth of work a piece. So again, thank you.

Please let me know if I have posted this question into the wrong forum.

I am trying to figure out how to get the innerhtml from certain tags after the Canvas Module on the page is created.

  Reveal hidden contents

What I am trying to get is the "Manage Installation: Foundation & Subflooring" from the aria-label. 

Project Information

  Reveal hidden contents

Current Code

  Reveal hidden contents

Let me know if you need any other information. There isn't an error; I just don't know how to pull out the innerHTML to do a verification check on which Module I am manipulating on the webpage. Please if there is a resource I am not using; please point me in the direction, looking to learn. 

Thank you again, 


Thomas

Edited by ThomasBennett
Left out a " in the code; made most of the code red; hard to read. Put the code and project information inside the spoiler so my post wouldn't take up so much room. Sorry for being rude.
Posted (edited)

@Danp2I never saw before an link-address inside with german special characters like ä, ö, ü or ß.

This is the first time. Standard to use in cases like that is to set ae, oe, ue or ss.

So, I will not be able to find a 2nd page with a link-address like that.

The original string of the address is : "#l%C3%B6hne_&_geh%C3%A4lter". In clear characters = "#löhne_&_gehälter"

I am not be able to recreate this link-address with PHP for a public available website for tests.

It seems that this link-address is created by a javascript function called encodeURI.

The result of the similar function of PHP urlencode is a other string: "l%F6hne_%26_geh%E4lter".

The original menu out of the none public application is:

  <ul class="tab-titles">
   <li class="first current arrow-tab payroll-tab">
    <a href="#fehlzeiten" data-index="0">
     <span>Fehlzeiten</span>
    </a>
   </li>
   <li class=" arrow-tab payroll-tab">
    <a href="#l%C3%B6hne_&amp;_geh%C3%A4lter" data-index="1">
     <span>Löhne & Gehälter</span>
    </a>
   </li>
   <li class="last payroll-tab">
    <a href="#abrechnung" data-index="2">
     <span>Abrechnung</span>
    </a>
   </li>
  </ul>

My feeling is that this application is complete developed in javascript. 

 

Edited by Hamburgo
Posted
Func TestPage()

DIM $Https    = "https://kmu-office.spdns.de/TDL/test/"

    _WD_Navigate($sSession, $Https)

    Sleep(5000)

   $sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='#l%C3%B6hne_&amp;_geh%C3%A4lter']")
;   $sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='#löhne_&_gehälter']")
;   $sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='#l&#xf6;hne_&#x26;_geh&#xe4;lter']")

   ConsoleWrite(@CRLF & "Link Ref: " & $sLink & @CRLF & @CRLF)
    ConsoleWrite("Before Click" & @CRLF & @CRLF)
    _WD_ElementAction($sSession, $sLink, 'click')    ;<
    Sleep(2000)
    ConsoleWrite("After Click" & @CRLF & @CRLF)

EndFunc   ;==>TestPage

On the top you will find a snipe of my script for test.

On the bottom you will find the out on the console:

>"D:\Develop\AutoIT\SciTE\..\autoit3.exe" /ErrorStdOut "D:\Develop\AutoIT\FireFox\WebDriver\WebDriver-TestPage.au3"    
@@ Debug line    158   var: $sFirefox --> D:\WWW\Firefox\firefox.exe

@@ Debug line    20   var: $aVerQueryValue --> 66.0.2
@@ Debug line    177   var: $sGeckoDriver --> .\geckodriver\geckodriver-v0.23.0-win64\geckodriver.exe

_WDStartup: OS:    WIN_10 WIN32_NT 17134
_WDStartup: AutoIt:    3.3.14.5
_WDStartup: WD.au3:    0.1.0.17
_WDStartup: Driver:    .\geckodriver\geckodriver-v0.23.0-win64\geckodriver.exe
_WDStartup: Params:    --log trace
_WDStartup: Port:    4444
__WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}
__WD_Post: StatusCode=200; ResponseText={"value":{"sessionId":"65759a56-1555-42c9-b359-0cb3f759fc7a","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"66.0.2","javascriptEnabled":true,"moz:accessibilityChecks":false,"moz:geckodriverVersion":"0.23.0","moz:headless":false,"moz:processID":14004,"moz:profile":"R:\\Temp\\rust_mozprofile.OpcRSAvnBurm","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"nativeEvents":true,"pageLoadStrategy":"normal","platformName":"windows","platformVersion":"10.0","rotatable":false,"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}}
_WD_CreateSession: {"value":{"sessionId":"65759a56-1555-42c9-b359-0cb3f759fc7a","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"66.0.2","javascriptEnabled":true,"moz:accessibilityChecks":false,"moz:geckodriverVersion":"0.23.0","moz:headless":false,"moz:processID":14004,"moz:profile":"R:\\Temp\\rust_mozprofile.OpcRSAvnBurm","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"nativeEvents":true,"pageLoadStrategy":"normal","platformName":"windows","platformVersion":"10.0","rotatable":false,"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"}}}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Running: TestPage

__WD_Post: URL=HTTP://127.0.0.1:4444/session/65759a56-1555-42c9-b359-0cb3f759fc7a/url; $sData={"url":"https://kmu-office.spdns.de/TDL/test/"}
__WD_Post: StatusCode=200; ResponseText={"value":null}
_WD_Navigate: {"value":null}
__WD_Post: URL=HTTP://127.0.0.1:4444/session/65759a56-1555-42c9-b359-0cb3f759fc7a/element; $sData={"using":"xpath","value":"//a[@href='#l%C3%B6hne_&amp;_geh%C3%A4lter']"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"Unable to locate element: //a[@href='#l%C3%B6hne_&amp;_geh%C3%A4lter']","stacktrace":"WebDriverError@chrome://marionette/content/error.js:179:5\nNoSuchElementError@chrome://marionette/content/error.js:389:5\nelement.find/</<@chrome://marionette/content/element.js:339:16\n"}}
_WD_FindElement: {"value":{"error":"no such element","message":"Unable to locate element: //a[@href='#l%C3%B6hne_&amp;_geh%C3%A4lter']","stacktrace":"WebDriverError@chrome://marionette/content/error.js:179:5\nNoSuchElementError@chrome://marionette/content/error.js:389:5\nelement.find/</<@chrome://marionette/content/element.js:339:16\n"}}
_WD_FindElement ==> No match: HTTP status = 404

Link Ref:

Before Click

__WD_Post: URL=HTTP://127.0.0.1:4444/session/65759a56-1555-42c9-b359-0cb3f759fc7a/element//click; $sData={"id":""}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"unknown command","message":"POST /session/65759a56-1555-42c9-b359-0cb3f759fc7a/element//click did not match a known command","stacktrace":""}}
_WD_ElementAction: {"value":{"error":"unknown command","message":"POST /session/65759a56-1555-42c9-b359-0cb3f759fc7a/el...
_WD_ElementAction ==> Webdriver Exception: {"value":{"error":"unknown command","message":"POST /session/65759a56-1555-42c9-b359-0cb3f759fc7a/element//click did not match a known command","stacktrace":""}}
After Click


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__WD_Delete: URL=HTTP://127.0.0.1:4444/session/65759a56-1555-42c9-b359-0cb3f759fc7a
__WD_Delete: StatusCode=200; ResponseText={"value":null}
_WD_DeleteSession: {"value":null}
>Exit code: 0    Time: 26.94

Posted (edited)

@Danp2 Thanks, I will try it, but I do not believe, that will help.

I believe in your example will also works:

$sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='bücher.ch']")

because on your site the string "bücher.ch" is inside the link-address as regular characters with a single ü.

In my case/page it will be the problem that the german special character like ü will be converted to %C3%BC.

So, I am sure, that a command like the follow will also not work:

$sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[contains(@href,'b%C3%BCcher.ch ')]")

I am sure that the problem comes from the url-encoding.

 

 

Edited by Hamburgo
Posted (edited)

@Danp2 Validation:
Command did not work:

$sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[contains(@href,'#l%C3%B6hne_&amp;_geh%C3%A4lter')]")

Consol-Output:

__WD_Post: URL=HTTP://127.0.0.1:4444/session/37130dae-c019-43db-a45e-1735f80784d0/element; $sData={"using":"xpath","value":"//a[contains(@href,'#l%C3%B6hne_&amp;_geh%C3%A4lter')]"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"Unable to locate element: //a[contains(@href,'#l%C3%B6hne_&amp;_geh%C3%A4lter')]","stacktrace":"WebDriverError@chrome://marionette/content/error.js:179:5\nNoSuchElementError@chrome://marionette/content/error.js:389:5\nelement.find/</<@chrome://marionette/content/element.js:339:16\n"}}
_WD_FindElement: {"value":{"error":"no such element","message":"Unable to locate element: //a[contains(@href,'#l%C3%B6hne_&amp;_geh%C3%A4lter')]","stacktrace":"WebDriverError@chrome://marionette/content/error.js:179:5\nNoSuchElementError@chrome://marionette/content/error.js:389:5\nelement.find/</<@chrome://marionette/content/element.js:339:16\n"}}
_WD_FindElement ==> No match: HTTP status = 404

 

Edited by Hamburgo
Posted (edited)

@Danp2 The a-tag has no ID, but a property "data-index":

<a href="#l%C3%B6hne_&amp;_geh%C3%A4lter" data-index="1">

Is it possible to search with data-index='1' ?

This property with this value is unique !

Edited by Hamburgo
Posted (edited)

@Danp2Ok, this information was very helpful.

Now, I know the real problem. It was not the german special characters in the link-address. Germans are think that, first.

The problem is the & = &amp;

In my test-site I am deleting the &amp; in the copy of the original-a-tag and than it works with this address, too.

And after a 2nd test I believe to know exactly the problem.

It is not the single character & = &amp;  It is the & in ALL html-entities like &OElig; etc., too.

Is there a possibility to escape the & or anything else ?

Or can I search with a part of link-adress like "#l%C3%B6hne_" ?     It is unique, too.

 

Edited by Hamburgo
Posted

@Danp2 If it inecessary to escape the ampersand in the link, than it will not work, because I do not have access to the application for that.

To search with a partical string works. This is the solution for my current problem. 😀

Both commands are running well:

   $sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[contains(@href,'#l%C3%B6hne_')]")
   $sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[contains(@href,'#l%C3%B6hne_') and contains(@href,'_geh%C3%A4lter')]")

Many thanks for your support.

Posted

The truth is a other one:
Html-entities are direct converted by the driver to the real single character, but not the url-codes für special characters, like the german once.

1.    $sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='#l%C3%B6hne_&amp;_geh%C3%A4lter']")
2.   $sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='#löhne_&_gehälter']")

3.   $sLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@href='#l%C3%B6hne_&_geh%C3%A4lter']")

1.  Do not work.    (Source-code of the original-page)

2.  Do not work.   (converted result of the browser, if hold the mouse over the original-link)

3.  This works.

 

Posted
  On 4/3/2019 at 9:41 AM, Hamburgo said:

Html-entities are direct converted by the driver to the real single character, but not the url-codes für special characters

Expand  

OIC. So just replace the HTML representation of the ampersand with the real thing and all is well, correct? Glad you were able to figure that out.

P.S. When I mentioned escaping the ampersand, I was suggesting to do that in your code, not in the source website.

Guest
This topic is now closed to further replies.
×
×
  • Create New...