Jump to content

WebDriver UDF - Help & Support (II)


Danp2
 Share

Recommended Posts

Thanks, I thought so.

I have another question,

Is there anyway to count the number of open tabs ?

I'm using portable chrome, with headless mode, my automation includes opening tabs for each process, so I want to know if the number of tabs exceed for example 10 open tabs, the browser closes and reopens the browser fresh, to avoid system resources overload.

Link to comment
Share on other sites

Hi Dan,
hi community.

Iam new here, but I already gained a lot of experience from your posts in this thread. Thanks for that!

I am currently building a script to get a specific text shown on a website. 

Basically this is the code I put in to find the number:

$sElementSelector = "//span[@id='trade_block_spot_price']"
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sElementSelector)
$sText = _WD_ElementAction($sSession, $sElement, 'property', 'innerText')

This is the element itself. I want to get the 53.50717:

<span class="patterns__info-val" id="trade_block_spot_price">53.50717</span>

The xpath:

//*[@id="trade_block_spot_price"]

The full xpath:

/html/body/aside/div[2]/div[1]/div/div/div[1]/form/ul/li[1]/span

I tried different variantes but I always get the following message shown on the sciTE console:

Spoiler
__WD_Post: URL=HTTP://127.0.0.1:9515/session/882510e3fc5ee0323136868b489d5be1/element; $sData={"using":"xpath","value":"//span[@id='trade_block_spot_price']"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\...
__WD_Post ==> No match: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"selector\":\"//span[@id='trade_block_spot_price']\"}\n  (Session info: chrome=87.0.4280.141)","stacktrace":"Backtrace:\n\tOrdinal0 [0x0046D983+3266947]\n\tOrdinal0 [0x0033B611+2012689]\n\tOrdinal0 [0x001DD0A2+577698]\n\tOrdinal0 [0x0016B642+112194]\n\tOrdinal0 [0x0018B962+244066]\n\tOrdinal0 [0x0017E30A+189194]\n\tOrdinal0 [0x0018A289+238217]\n\tOrdinal0 [0x0017E17B+188795]\n\tOrdinal0 [0x001634AA+79018]\n\tOrdinal0 [0x001645A0+83360]\n\tOrdinal0 [0x00164539+83257]\n\tOrdinal0 [0x003539EB+2111979]\n\tGetHandleVerifier [0x005A7C26+1175878]\n\tGetHandleVerifier [0x005A78BC+1175004]\n\tGetHandleVerifier [0x005BA1DF+1251071]\n\tGetHandleVerifier [0x005A84AB+1178059]\n\tOrdinal0 [0x0034A504+2073860]\n\tOrdinal0 [0x00355A7B+2120315]\n\tOrdinal0 [0x00355BFD+2120701]\n\tOrdinal0 [0x00368D75+2198901]\n\tBaseThreadInitThunk [0x75EC23D9+25]\n\tRtlExpandEnvironmentStrings [0x776BB94C+1020]\n\tRtlExpandEnvironmentStrings [0x776BB920+976]\n"}}
_WD_FindElement: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"selector\":\"//span[@id='trade_block_spot_price']\"}\n  (Session info: chrome=87.0.4280.141)","stacktrace":"Backtrace:\n\tOrdinal0 [0x0046D983+3266947]\n\tOrdinal0 [0x0033B611+2012689]\n\tOrdinal0 [0x001DD0A2+577698]\n\tOrdinal0 [0x0016B642+112194]\n\tOrdinal0 [0x0018B962+244066]\n\tOrdinal0 [0x0017E30A+189194]\n\tOrdinal0 [0x0018A289+238217]\n\tOrdinal0 [0x0017E17B+188795]\n\tOrdinal0 [0x001634AA+79018]\n\tOrdinal0 [0x001645A0+83360]\n\tOrdinal0 [0x00164539+83257]\n\tOrdinal0 [0x003539EB+2111979]\n\tGetHandleVerifier [0x005A7C26+1175878]\n\tGetHandleVerifier [0x005A78BC+1175004]\n\tGetHandleVerifier [0x005BA1DF+1251071]\n\tGetHandleVerifier [0x005A84AB+1178059]\n\tOrdinal0 [0x0034A504+2073860]\n\tOrdinal0 [0x00355A7B+2120315]\n\tOrdinal0 [0x00355BFD+2120701]\n\tOrdinal0 [0x00368D75+2198901]\n\tBaseThreadInitThunk [0x75EC23D9+25]\n\tRtlExpandEnvironmentStrings [0x776BB94C+1020]\n\tRtlExpandEnvironmentStrings [0x776BB920+976]\n"}}
_WD_FindElement ==> No match: HTTP status = 404
__WD_Get: URL=HTTP://127.0.0.1:9515/session/882510e3fc5ee0323136868b489d5be1/element//property/innerText
__WD_Get: StatusCode=404; $iResult = 8; $sResponseText={"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Ses...
__WD_Get ==> No match: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Session info: chrome=87.0.4280.141)","stacktrace":"Backtrace:\n\tOrdinal0 [0x0046D983+3266947]\n\tOrdinal0 [0x0033B611+2012689]\n\tOrdinal0 [0x001DD0A2+577698]\n\tOrdinal0 [0x0016AE98+110232]\n\tOrdinal0 [0x00166D04+93444]\n\tOrdinal0 [0x0017E2D3+189139]\n\tOrdinal0 [0x001651B6+86454]\n\tOrdinal0 [0x0017E50A+189706]\n\tOrdinal0 [0x0018A289+238217]\n\tOrdinal0 [0x0017E17B+188795]\n\tOrdinal0 [0x001634AA+79018]\n\tOrdinal0 [0x001645A0+83360]\n\tOrdinal0 [0x00164539+83257]\n\tOrdinal0 [0x003539EB+2111979]\n\tGetHandleVerifier [0x005A7C26+1175878]\n\tGetHandleVerifier [0x005A78BC+1175004]\n\tGetHandleVerifier [0x005BA1DF+1251071]\n\tGetHandleVerifier [0x005A84AB+1178059]\n\tOrdinal0 [0x0034A504+2073860]\n\tOrdinal0 [0x00355A7B+2120315]\n\tOrdinal0 [0x00355BFD+2120701]\n\tOrdinal0 [0x00368D75+2198901]\n\tBaseThreadInitThunk [0x75EC23D9+25]\n\tRtlExpandEnvironmentStrings [0x776BB94C+1020]\n\tRtlExpandEnvironmentStrings [0x776BB920+976]\n"}}
_WD_ElementAction: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Ses...
_WD_ElementAction ==> No match: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Session info: chrome=87.0.4280.141)","stacktrace":"Backtrace:\n\tOrdinal0 [0x0046D983+3266947]\n\tOrdinal0 [0x0033B611+2012689]\n\tOrdinal0 [0x001DD0A2+577698]\n\tOrdinal0 [0x0016AE98+110232]\n\tOrdinal0 [0x00166D04+93444]\n\tOrdinal0 [0x0017E2D3+189139]\n\tOrdinal0 [0x001651B6+86454]\n\tOrdinal0 [0x0017E50A+189706]\n\tOrdinal0 [0x0018A289+238217]\n\tOrdinal0 [0x0017E17B+188795]\n\tOrdinal0 [0x001634AA+79018]\n\tOrdinal0 [0x001645A0+83360]\n\tOrdinal0 [0x00164539+83257]\n\tOrdinal0 [0x003539EB+2111979]\n\tGetHandleVerifier [0x005A7C26+1175878]\n\tGetHandleVerifier [0x005A78BC+1175004]\n\tGetHandleVerifier [0x005BA1DF+1251071]\n\tGetHandleVerifier [0x005A84AB+1178059]\n\tOrdinal0 [0x0034A504+2073860]\n\tOrdinal0 [0x00355A7B+2120315]\n\tOrdinal0 [0x00355BFD+2120701]\n\tOrdinal0 [0x00368D75+2198901]\n\tBaseThreadInitThunk [0x75EC23D9+25]\n\tRtlExpandEnvironmentStrings [0x776BB94C+1020]\n\tRtlExpandEnvironmentStrings [0x776BB920+976]\n"}}

 

I already rebuild my system environment (like mentioned in the wiki)because somehow in my very first try it was working. After I build around that small script part a couple of days later it was not working anymore. Now I restarted from scratch with just that basic code and its still not working.

Maybe it has to do with the complex structure of the website. The element is inside this sidebar (shown on the attached screenshot.)

Basically I can for example get another text (751,163.455) from the upper bar which is not that far down in the tree:

code used:
$sElementSelector = "//span[@id='account_current_balance_usd']"
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sElementSelector)
$sText = _WD_ElementAction($sSession, $sElement, 'property', 'innerText')

copy of element:
<span id="account_current_balance_usd" class="" original-title="Additional $ reserved in escrow">751,163.455</span>
xpath:
//*[@id="account_current_balance_usd"]
Full xpath:
/html/body/div[3]/header/div[2]/div[3]/a/p/span

 

Thanks for any help and suggestion.

greetings

PaddyHeady

overview_of_website.png

Link to comment
Share on other sites

@PaddyHeady Reply here instead of PM so that everyone can benefit --

I can't access the site (blocked by Cloudflare; maybe geographic restrictions?). Looking at the HTML source, there are clearly iframes present. If your desired element is contained within a frame, then you must switch to the frame before you can access the element.

Link to comment
Share on other sites

Just now, Danp2 said:

@PaddyHeady Reply here instead of PM so that everyone can benefit --

I can't access the site (blocked by Cloudflare; maybe geographic restrictions?). Looking at the HTML source, there are clearly iframes present. If your desired element is contained within a frame, then you must switch to the frame before you can access the element.

Yes seems like US is restricted. 

Thanks for your reply. I will look further into how to switch to the right iframe.

 

Link to comment
Share on other sites

Hello,

I am trying to pass variable from keyboard using:

$sUsername = $CmdLine[1]
sPassword = $CmdLine[2]

and put it into fields on the twitter login page:

$sElement = _WD_GetElementByName($sSession, "session[username_or_email]")
If Not @error Then _WD_SetElementValue($sSession, $sElement, $sUsername)

$sElement = _WD_GetElementByName($sSession, "session[password]")
If Not @error Then _WD_SetElementValue($sSession, $sElement, sPassword)

I worked few times, but after few compilations it can't find my elements 😕

log:

[1611692694.520][INFO]: Starting ChromeDriver 87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280@{#1761}) on port 9515
[1611692694.521][INFO]: Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
[1611692694.956][INFO]: [70de11a33707d3a412d284f637f6b084] COMMAND InitSession {
   "capabilities": {
      "alwaysMatch": {
         "goog:chromeOptions": {
            "excludeSwitches": [ "enable-automation" ],
            "useAutomationExtension": false,
            "w3c": true
         }
      }
   }
}
[1611692694.957][WARNING]: Deprecated chrome option is ignored: useAutomationExtension
[1611692694.957][WARNING]: Deprecated chrome option is ignored: useAutomationExtension
[1611692694.960][INFO]: Populating Preferences file: {
   "alternate_error_pages": {
      "enabled": false
   },
   "autofill": {
      "enabled": false
   },
   "browser": {
      "check_default_browser": false
   },
   "distribution": {
      "import_bookmarks": false,
      "import_history": false,
      "import_search_engine": false,
      "make_chrome_default_for_user": false,
      "skip_first_run_ui": true
   },
   "dns_prefetching": {
      "enabled": false
   },
   "profile": {
      "content_settings": {
         "pattern_pairs": {
            "https://*,*": {
               "media-stream": {
                  "audio": "Default",
                  "video": "Default"
               }
            }
         }
      },
      "default_content_setting_values": {
         "geolocation": 1
      },
      "default_content_settings": {
         "geolocation": 1,
         "mouselock": 1,
         "notifications": 1,
         "popups": 1,
         "ppapi-broker": 1
      },
      "password_manager_enabled": false
   },
   "safebrowsing": {
      "enabled": false
   },
   "search": {
      "suggest_enabled": false
   },
   "translate": {
      "enabled": false
   }
}
[1611692694.961][INFO]: Populating Local State file: {
   "background_mode": {
      "enabled": false
   },
   "ssl": {
      "rev_checking": {
         "enabled": false
      }
   }
}
[1611692694.963][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-backgrounding-occluded-windows --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-blink-features=ShadowDOMV0 --enable-logging --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\LUKASZ~1.RES\AppData\Local\Temp\2\scoped_dir912_374730974" data:,
[1611692695.316][DEBUG]: DevTools HTTP Request: http://localhost:51295/json/version
[1611692695.623][DEBUG]: DevTools HTTP Response: {

   "Browser": "Chrome/88.0.4324.104",

   "Protocol-Version": "1.3",

   "User-Agent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36",

   "V8-Version": "8.8.278.14",

   "WebKit-Version": "537.36 (@17905c015d3376dee9cce5dd079a3f4fa906e060)",

   "webSocketDebuggerUrl": "ws://localhost:51295/devtools/browser/14477ca1-b247-4d73-8468-f00d0aab3e70"

}


[1611692695.624][WARNING]: This version of ChromeDriver has not been tested with Chrome version 88.
[1611692695.624][DEBUG]: DevTools HTTP Request: http://localhost:51295/json/list
[1611692695.626][DEBUG]: DevTools HTTP Response: [ {

   "description": "",

   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:51295/devtools/page/B91126E4F2D920E2F4EC9F74B8C9DAD9",

   "id": "B91126E4F2D920E2F4EC9F74B8C9DAD9",

   "title": "",

   "type": "page",

   "url": "data:,",

   "webSocketDebuggerUrl": "ws://localhost:51295/devtools/page/B91126E4F2D920E2F4EC9F74B8C9DAD9"

} ]


[1611692695.626][DEBUG]: DevTools HTTP Request: http://localhost:51295/json/list
[1611692695.627][DEBUG]: DevTools HTTP Response: [ {

   "description": "",

   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:51295/devtools/page/B91126E4F2D920E2F4EC9F74B8C9DAD9",

   "id": "B91126E4F2D920E2F4EC9F74B8C9DAD9",

   "title": "",

   "type": "page",

   "url": "data:,",

   "webSocketDebuggerUrl": "ws://localhost:51295/devtools/page/B91126E4F2D920E2F4EC9F74B8C9DAD9"

} ]


[1611692695.630][INFO]: resolved localhost to ["::1","127.0.0.1"]
[1611692696.639][DEBUG]: DevTools WebSocket Command: Page.addScriptToEvaluateOnNewDocument (id=1) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "source": "(function () {window.cdc_adoQpoasnfa76pfcZLmcfl_Array = window.Array;window.cdc_adoQpoasnfa76pfcZLmcfl_Promise = window.Promise;window.cdc_adoQpoasnfa76pfcZLmcfl_Symbol = window.Symbol;}) ();"
}
[1611692696.639][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=2) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "(function () {window.cdc_adoQpoasnfa76pfcZLmcfl_Array = window.Array;window.cdc_adoQpoasnfa76pfcZLmcfl_Promise = window.Promise;window.cdc_adoQpoasnfa76pfcZLmcfl_Symbol = window.Symbol;}) ();"
}
[1611692696.639][DEBUG]: DevTools WebSocket Command: Log.enable (id=3) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.639][DEBUG]: DevTools WebSocket Command: DOM.getDocument (id=4) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.640][DEBUG]: DevTools WebSocket Command: Target.setAutoAttach (id=5) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "autoAttach": true,
   "flatten": true,
   "waitForDebuggerOnStart": false
}
[1611692696.640][DEBUG]: DevTools WebSocket Command: Page.enable (id=6) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.640][DEBUG]: DevTools WebSocket Command: Page.enable (id=7) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.640][DEBUG]: DevTools WebSocket Response: Page.addScriptToEvaluateOnNewDocument (id=1) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "identifier": "1"
}
[1611692696.640][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=2) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "type": "undefined"
   }
}
[1611692696.640][DEBUG]: DevTools WebSocket Response: Log.enable (id=3) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.640][DEBUG]: DevTools WebSocket Response: DOM.getDocument (id=4) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "root": {
      "backendNodeId": 2,
      "baseURL": "data:,",
      "childNodeCount": 1,
      "children": [ {
         "attributes": [  ],
         "backendNodeId": 3,
         "childNodeCount": 2,
         "children": [ {
            "attributes": [  ],
            "backendNodeId": 4,
            "childNodeCount": 0,
            "localName": "head",
            "nodeId": 3,
            "nodeName": "HEAD",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 2
         }, {
            "attributes": [  ],
            "backendNodeId": 5,
            "childNodeCount": 0,
            "localName": "body",
            "nodeId": 4,
            "nodeName": "BODY",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 2
         } ],
         "frameId": "B91126E4F2D920E2F4EC9F74B8C9DAD9",
         "localName": "html",
         "nodeId": 2,
         "nodeName": "HTML",
         "nodeType": 1,
         "nodeValue": "",
         "parentId": 1
      } ],
      "documentURL": "data:,",
      "localName": "",
      "nodeId": 1,
      "nodeName": "#document",
      "nodeType": 9,
      "nodeValue": "",
      "xmlVersion": ""
   }
}
[1611692696.641][DEBUG]: DevTools WebSocket Response: Target.setAutoAttach (id=5) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.641][DEBUG]: DevTools WebSocket Response: Page.enable (id=6) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.641][DEBUG]: DevTools WebSocket Response: Page.enable (id=7) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.641][DEBUG]: DevTools WebSocket Command: Runtime.enable (id=8) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.641][DEBUG]: DevTools WebSocket Event: Runtime.executionContextCreated B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "context": {
      "auxData": {
         "frameId": "B91126E4F2D920E2F4EC9F74B8C9DAD9",
         "isDefault": true,
         "type": "default"
      },
      "id": 1,
      "name": "",
      "origin": "://"
   }
}
[1611692696.641][DEBUG]: DevTools WebSocket Response: Runtime.enable (id=8) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.641][DEBUG]: DevTools WebSocket Command: Page.enable (id=9) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.642][DEBUG]: DevTools WebSocket Response: Page.enable (id=9) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.642][DEBUG]: DevTools WebSocket Command: Runtime.enable (id=10) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.643][DEBUG]: DevTools WebSocket Response: Runtime.enable (id=10) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.643][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=11) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "awaitPromise": true,
   "expression": "(function() { // Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Enum f...",
   "returnByValue": true
}
[1611692696.646][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=11) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "type": "object",
      "value": {
         "status": 0,
         "value": 1
      }
   }
}
[1611692696.646][INFO]: [70de11a33707d3a412d284f637f6b084] RESPONSE InitSession {
   "capabilities": {
      "acceptInsecureCerts": false,
      "browserName": "chrome",
      "browserVersion": "88.0.4324.104",
      "chrome": {
         "chromedriverVersion": "87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280@{#1761})",
         "userDataDir": "C:\\Users\\LUKASZ~1.RES\\AppData\\Local\\Temp\\2\\scoped_dir912_374730974"
      },
      "goog:chromeOptions": {
         "debuggerAddress": "localhost:51295"
      },
      "networkConnectionEnabled": false,
      "pageLoadStrategy": "normal",
      "platformName": "windows",
      "proxy": {

      },
      "setWindowRect": true,
      "strictFileInteractability": false,
      "timeouts": {
         "implicit": 0,
         "pageLoad": 300000,
         "script": 30000
      },
      "unhandledPromptBehavior": "dismiss and notify",
      "webauthn:virtualAuthenticators": true
   },
   "sessionId": "70de11a33707d3a412d284f637f6b084"
}
[1611692696.664][INFO]: [70de11a33707d3a412d284f637f6b084] COMMAND Navigate {
   "url": "https://twitter.com/login"
}
[1611692696.664][INFO]: Waiting for pending navigations...
[1611692696.664][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=12) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "1"
}
[1611692696.665][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=12) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1611692696.665][DEBUG]: DevTools WebSocket Command: DOM.getDocument (id=13) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.666][DEBUG]: DevTools WebSocket Response: DOM.getDocument (id=13) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "root": {
      "backendNodeId": 2,
      "baseURL": "data:,",
      "childNodeCount": 1,
      "children": [ {
         "attributes": [  ],
         "backendNodeId": 3,
         "childNodeCount": 2,
         "children": [ {
            "attributes": [  ],
            "backendNodeId": 4,
            "childNodeCount": 0,
            "localName": "head",
            "nodeId": 7,
            "nodeName": "HEAD",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 6
         }, {
            "attributes": [  ],
            "backendNodeId": 5,
            "childNodeCount": 0,
            "localName": "body",
            "nodeId": 8,
            "nodeName": "BODY",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 6
         } ],
         "frameId": "B91126E4F2D920E2F4EC9F74B8C9DAD9",
         "localName": "html",
         "nodeId": 6,
         "nodeName": "HTML",
         "nodeType": 1,
         "nodeValue": "",
         "parentId": 5
      } ],
      "documentURL": "data:,",
      "localName": "",
      "nodeId": 5,
      "nodeName": "#document",
      "nodeType": 9,
      "nodeValue": "",
      "xmlVersion": ""
   }
}
[1611692696.666][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=14) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "awaitPromise": false,
   "expression": "document.readyState",
   "returnByValue": true
}
[1611692696.666][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=14) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "type": "string",
      "value": "complete"
   }
}
[1611692696.666][INFO]: Done waiting for pending navigations. Status: ok
[1611692696.666][DEBUG]: DevTools WebSocket Command: Page.navigate (id=15) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "url": "https://twitter.com/login"
}
[1611692696.876][DEBUG]: DevTools WebSocket Response: Page.navigate (id=15) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "frameId": "B91126E4F2D920E2F4EC9F74B8C9DAD9",
   "loaderId": "8315E2A145DE20186A28C85BB38DCA06"
}
[1611692696.876][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=16) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "document.URL"
}
[1611692696.878][DEBUG]: DevTools WebSocket Event: Runtime.executionContextsCleared B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.879][DEBUG]: DevTools WebSocket Event: Page.frameStartedLoading B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "frameId": "B91126E4F2D920E2F4EC9F74B8C9DAD9"
}
[1611692696.893][DEBUG]: DevTools WebSocket Event: Runtime.executionContextsCleared B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.893][DEBUG]: DevTools WebSocket Event: Page.frameNavigated B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "frame": {
      "adFrameType": "none",
      "crossOriginIsolatedContextType": "NotIsolated",
      "domainAndRegistry": "twitter.com",
      "gatedAPIFeatures": [ "SharedArrayBuffers", "SharedArrayBuffersTransferAllowed" ],
      "id": "B91126E4F2D920E2F4EC9F74B8C9DAD9",
      "loaderId": "8315E2A145DE20186A28C85BB38DCA06",
      "mimeType": "text/html",
      "secureContextType": "Secure",
      "securityOrigin": "https://twitter.com",
      "url": "https://twitter.com/login"
   }
}
[1611692696.893][DEBUG]: DevTools WebSocket Event: DOM.documentUpdated B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.893][DEBUG]: DevTools WebSocket Command: DOM.getDocument (id=17) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692696.894][DEBUG]: DevTools WebSocket Event: Runtime.executionContextCreated B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "context": {
      "auxData": {
         "frameId": "B91126E4F2D920E2F4EC9F74B8C9DAD9",
         "isDefault": true,
         "type": "default"
      },
      "id": 1,
      "name": "",
      "origin": "https://twitter.com"
   }
}
[1611692696.900][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=16) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "type": "string",
      "value": "https://twitter.com/login"
   }
}
[1611692696.900][INFO]: Waiting for pending navigations...
[1611692696.900][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=18) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "1"
}
[1611692696.905][DEBUG]: DevTools WebSocket Response: DOM.getDocument (id=17) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "root": {
      "backendNodeId": 1,
      "baseURL": "https://twitter.com/login",
      "childNodeCount": 2,
      "children": [ {
         "backendNodeId": 2,
         "localName": "",
         "nodeId": 2,
         "nodeName": "html",
         "nodeType": 10,
         "nodeValue": "",
         "parentId": 1,
         "publicId": "",
         "systemId": ""
      }, {
         "attributes": [ "dir", "ltr", "lang", "en" ],
         "backendNodeId": 3,
         "childNodeCount": 2,
         "children": [ {
            "attributes": [  ],
            "backendNodeId": 4,
            "childNodeCount": 82,
            "localName": "head",
            "nodeId": 4,
            "nodeName": "HEAD",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 3
         }, {
            "attributes": [  ],
            "backendNodeId": 5,
            "childNodeCount": 2,
            "localName": "body",
            "nodeId": 5,
            "nodeName": "BODY",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 3
         } ],
         "frameId": "B91126E4F2D920E2F4EC9F74B8C9DAD9",
         "localName": "html",
         "nodeId": 3,
         "nodeName": "HTML",
         "nodeType": 1,
         "nodeValue": "",
         "parentId": 1
      } ],
      "documentURL": "https://twitter.com/login",
      "localName": "",
      "nodeId": 1,
      "nodeName": "#document",
      "nodeType": 9,
      "nodeValue": "",
      "xmlVersion": ""
   }
}
[1611692696.906][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=18) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1611692696.918][DEBUG]: DevTools WebSocket Event: DOM.childNodeCountUpdated B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "childNodeCount": 3,
   "nodeId": 5
}
[1611692696.918][DEBUG]: DevTools WebSocket Event: DOM.childNodeCountUpdated B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "childNodeCount": 4,
   "nodeId": 5
}
[1611692696.918][DEBUG]: DevTools WebSocket Event: DOM.childNodeCountUpdated B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "childNodeCount": 5,
   "nodeId": 5
}
[1611692696.918][DEBUG]: DevTools WebSocket Event: DOM.childNodeCountUpdated B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "childNodeCount": 6,
   "nodeId": 5
}
[1611692696.918][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=19) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "1"
}
[1611692696.919][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=19) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1611692696.989][DEBUG]: DevTools WebSocket Event: DOM.childNodeCountUpdated B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "childNodeCount": 7,
   "nodeId": 5
}
[1611692696.989][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=20) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "1"
}
[1611692696.990][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=20) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1611692697.055][DEBUG]: DevTools WebSocket Event: DOM.childNodeCountUpdated B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "childNodeCount": 8,
   "nodeId": 5
}
[1611692697.055][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=21) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "1"
}
[1611692697.055][DEBUG]: DevTools WebSocket Event: DOM.childNodeCountUpdated B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "childNodeCount": 9,
   "nodeId": 5
}
[1611692697.056][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=21) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1611692697.277][DEBUG]: DevTools WebSocket Event: DOM.childNodeCountUpdated B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "childNodeCount": 83,
   "nodeId": 4
}
[1611692697.277][DEBUG]: DevTools WebSocket Event: DOM.childNodeCountUpdated B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "childNodeCount": 10,
   "nodeId": 5
}
[1611692697.277][DEBUG]: DevTools WebSocket Event: DOM.childNodeCountUpdated B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "childNodeCount": 11,
   "nodeId": 5
}
[1611692697.277][DEBUG]: DevTools WebSocket Event: DOM.documentUpdated B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692697.277][DEBUG]: DevTools WebSocket Command: DOM.getDocument (id=22) B91126E4F2D920E2F4EC9F74B8C9DAD9 {

}
[1611692697.277][DEBUG]: DevTools WebSocket Event: Page.domContentEventFired B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "timestamp": 254704.946914
}
[1611692697.277][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=23) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "1"
}
[1611692697.282][DEBUG]: DevTools WebSocket Response: DOM.getDocument (id=22) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "root": {
      "backendNodeId": 1,
      "baseURL": "https://twitter.com/login",
      "childNodeCount": 2,
      "children": [ {
         "backendNodeId": 2,
         "localName": "",
         "nodeId": 7,
         "nodeName": "html",
         "nodeType": 10,
         "nodeValue": "",
         "parentId": 6,
         "publicId": "",
         "systemId": ""
      }, {
         "attributes": [ "dir", "ltr", "lang", "en", "style", "overflow-y: scroll; overscroll-behavior-y: none;" ],
         "backendNodeId": 3,
         "childNodeCount": 2,
         "children": [ {
            "attributes": [  ],
            "backendNodeId": 4,
            "childNodeCount": 83,
            "localName": "head",
            "nodeId": 9,
            "nodeName": "HEAD",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 8
         }, {
            "attributes": [  ],
            "backendNodeId": 5,
            "childNodeCount": 11,
            "localName": "body",
            "nodeId": 10,
            "nodeName": "BODY",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 8
         } ],
         "frameId": "B91126E4F2D920E2F4EC9F74B8C9DAD9",
         "localName": "html",
         "nodeId": 8,
         "nodeName": "HTML",
         "nodeType": 1,
         "nodeValue": "",
         "parentId": 6
      } ],
      "documentURL": "https://twitter.com/login",
      "localName": "",
      "nodeId": 6,
      "nodeName": "#document",
      "nodeType": 9,
      "nodeValue": "",
      "xmlVersion": ""
   }
}
[1611692697.282][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=23) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1611692697.284][DEBUG]: DevTools WebSocket Event: Page.loadEventFired B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "timestamp": 254704.953655
}
[1611692697.285][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=24) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "awaitPromise": false,
   "expression": "document.readyState",
   "returnByValue": true
}
[1611692697.285][DEBUG]: DevTools WebSocket Event: Page.frameStoppedLoading B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "frameId": "B91126E4F2D920E2F4EC9F74B8C9DAD9"
}
[1611692697.285][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=24) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "type": "string",
      "value": "complete"
   }
}
[1611692697.285][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=25) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "1"
}
[1611692697.286][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=25) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1611692697.286][INFO]: Done waiting for pending navigations. Status: ok
[1611692697.286][INFO]: [70de11a33707d3a412d284f637f6b084] RESPONSE Navigate
[1611692697.290][INFO]: [70de11a33707d3a412d284f637f6b084] COMMAND FindElement {
   "using": "xpath",
   "value": "//*[@name=\"session[username_or_email]\"]"
}
[1611692697.290][INFO]: Waiting for pending navigations...
[1611692697.291][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=26) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "1"
}
[1611692697.291][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=26) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1611692697.291][INFO]: Done waiting for pending navigations. Status: ok
[1611692697.293][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=27) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "awaitPromise": true,
   "expression": "(function() { // Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Enum f...",
   "returnByValue": true
}
[1611692697.301][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=27) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "type": "object",
      "value": {
         "status": 0,
         "value": null
      }
   }
}
[1611692697.301][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=28) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "1"
}
[1611692697.302][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=28) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1611692697.302][INFO]: Waiting for pending navigations...
[1611692697.302][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=29) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "1"
}
[1611692697.302][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=29) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1611692697.302][INFO]: Done waiting for pending navigations. Status: ok
[1611692697.302][INFO]: [70de11a33707d3a412d284f637f6b084] RESPONSE FindElement ERROR no such element: Unable to locate element: {"method":"xpath","selector":"//*[@name="session[username_or_email]"]"}
  (Session info: chrome=88.0.4324.104)
[1611692697.308][INFO]: [70de11a33707d3a412d284f637f6b084] COMMAND FindElement {
   "using": "xpath",
   "value": "//*[@name=\"session[password]\"]"
}
[1611692697.308][INFO]: Waiting for pending navigations...
[1611692697.308][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=30) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "1"
}
[1611692697.309][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=30) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1611692697.309][INFO]: Done waiting for pending navigations. Status: ok
[1611692697.311][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=31) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "awaitPromise": true,
   "expression": "(function() { // Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Enum f...",
   "returnByValue": true
}
[1611692697.317][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=31) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "type": "object",
      "value": {
         "status": 0,
         "value": null
      }
   }
}
[1611692697.317][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=32) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "1"
}
[1611692697.318][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=32) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1611692697.318][INFO]: Waiting for pending navigations...
[1611692697.318][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=33) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "expression": "1"
}
[1611692697.318][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=33) B91126E4F2D920E2F4EC9F74B8C9DAD9 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[1611692697.318][INFO]: Done waiting for pending navigations. Status: ok
[1611692697.318][INFO]: [70de11a33707d3a412d284f637f6b084] RESPONSE FindElement ERROR no such element: Unable to locate element: {"method":"xpath","selector":"//*[@name="session[password]"]"}
  (Session info: chrome=88.0.4324.104)

 

Link to comment
Share on other sites

@Wo0ki3 It may not have any effect, but your version of Chromedriver doesn't match your version of Chrome. You may want to update to a newer version of Chromedriver and then try again.

If the issue still occurs, then suggest that you post a short script that we can run to reproduce this issue. You could also try running with another browser (Firefox, Edge, etc) to see if the behavior can be reproduced elsewhere.

Link to comment
Share on other sites

Does Chromedriver need to be at the same version as Chrome? After update my chromedriver version is 88.0.4324.96 and chrome is 88.0.4324.104.

My code:

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

Local $sDesiredCapabilities, $sSession, $sElement
SetupChrome ()

$sUsername = $CmdLine[1]
$Password = $CmdLine[2]

_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://twitter.com/login")

$sElement = _WD_GetElementByName($sSession, "session[username_or_email]")
If Not @error Then _WD_SetElementValue($sSession, $sElement, $sUsername)

$sElement = _WD_GetElementByName($sSession, "session[password]")
If Not @error Then _WD_SetElementValue($sSession, $sElement, $Password)

_WD_Shutdown()

Func SetupChrome()
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}}'
EndFunc

 

Link to comment
Share on other sites

I think you are ok as long as the major version numbers match. So you encounter the issue by just running this script repeatedly?

Have you tried adding the following before the _WD_Shutdown?

_WD_DeleteSession($sSession)

Edit:

Ok... so the issue is that the code is executing before the webpage has finished loading. You'll need to add something like the following after your _WD_Navigate --

_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@type='text']")

 

Edited by Danp2
Link to comment
Share on other sites

How do you locate the XPath? I tried some chrome extensions, but the code that I am getting from them don't work with my scripts 😕 

For example, I am trying to click on Accept on: https://fortigate.fortidemo.com/login. My xpath is: 

/html/body/div[1]/div/div/div[3]/div/form/button[1]

in my code:

$sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div[1]/div/div/div[3]/div/form/button[1]")
_WD_ElementAction($sSession, $sButton, 'click')

 

Link to comment
Share on other sites

Your sample clarifies a lot for me! Thank you :)

 

What about when the button doesn't have a "name"?

<button class="button primary ng-binding" ng-click="$ctrl.loginReadOnly()">
                    Login Read-Only
                </button>

 

EDIT:

I have installed the chropath on Edge and it helps a lot. Much better than the other addons.

But still, this button that I posted earlier, I can't click it 😕

Edited by Wo0ki3
change
Link to comment
Share on other sites

Hi Dan,

I have a strange problem:

Sometimes an error occurs when deleting a session and the script ends.
I'm trying to catch the error like this:

_WD_DeleteSession($arrsh[$i])
            If @error = $_WD_ERROR_Exception Then
                ShellExecute('taskkill.exe', '/IM "chrome.exe" /F')
                Exit
            EndIf

But nothing happens, the script crashes

In the console, the error looks like this:

_WD_DeleteSession($arrsh[$i])
_WD_DeleteSession(^ ERROR

 

Edited by sarge
Link to comment
Share on other sites

Like this:

_WD_Navigate($sSession, "https://m.test.com/test/")
Sleep (Random(2500,3000,4000))
$aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@class='broadcaster-cell']", Default, True)
_WD_ElementAction($sSession, $aElements[Random(0,UBound($aElements)-1,1)], 'click')
Sleep (Random(2500,3000,4000))
_ArrayAdd($arrsh, $sSession)

I just noticed that a similar error occurs when you select a session window and do something there ...
For example, you go to the previous page.
Or even just when selected, it is not covered by a script ...

Link to comment
Share on other sites

4 hours ago, sarge said:

$aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@class='broadcaster-cell']", Default, True) _WD_ElementAction($sSe

What happens if no elements are found? I would recommend checking @error following the call to _WD_FindElement.

4 hours ago, sarge said:

_ArrayAdd($arrsh, $sSession)

  • Can you elaborate why you are doing this?
  • That shows where you are adding the session to the array, but doesn't show where the array is originally declared.
  • If you must capture the session in an array, why not do it at the point the session is created?
4 hours ago, sarge said:

I just noticed that a similar error occurs when you select a session window and do something there

Sorry, but I don't understand what you are attempting to describe. Best bet is to post a short reproducer script that we can run to observe the issue.

Link to comment
Share on other sites

  • 2 weeks later...

Hello @Danp2 I have this part of script

Func _CreationTicket1 ()                                            ;Création ticket 1
    ToolTip ( "Exist seek new incident" , 1 , 1 )
    WinActivate("Google")
    Send("^q")
    Sleep(1500)
    Local $sFrame = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//frame[@id='main']")
    _WD_FrameEnter($sSession, $sFrame)
    ConsoleWrite("TopWindow=" & _WD_IsWindowTop($sSession) & @CRLF)
    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[contains(@id,'ORIG_t')]")
    _WD_ElementAction($sSession, $sElement, 'click' )
    Sleep(200)
    _WD_ElementAction($sSession, $sElement, 'value' , 'm' )
    Send("{ENTER}")
    Sleep(1000)
EndFunc ;=>_CreationTicket1 ()

The purpose is simple pop up a combo list and send m and select the element. 

image.png.d38ae1fdf67287f09738a48ec63e48ed.png

I tried the example from the wiki trying to adapt it to my needs. Didn't success to select the item without such bad lines like that. Could you lead me the right direction again please ?

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

@caramen You should already know that Send() should only be used as a last resort. What are you attempting to do here?

WinActivate("Google")
    Send("^q")

It's difficult to know how to guide you without further details, such as --

  • Results from Scite output panel so that we can see success / failure of your calls to the UDF
  • HTML for the web page or at least the element you need to control

FWIW, you may be able to use _WD_ElementOptionSelect to select the desired entry in the combo list.

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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