Jump to content

Help with _WD_ElementOptionSelec


Recommended Posts

I'm wondering how I should be using this? 

Is this correct? 

I'm putting the Xpath followed by "//option[2]" but I don't think this is correct 

_WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="titleInProceedings"]/div/div[1]/div[1]//option[2]')

But this fails because it's now looking for an xpath with //option[2] on the end. 

Log

_WD_FindElement ==> No match [8] : Parameters:   Strategy=xpath   Selector=//*[@id="titleInProceedings"]/div/div[1]/div[1]//option[2]   StartNodeID=   Multiple=Default   ShadowRoot=Default
_WD_ElementOptionSelect ==> No match [8] : Parameters:    Strategy=xpath    Selector=//*[@id="titleInProceedings"]/div/div[1]/div[1]//option[2]    StartElement=Default

Can anyone post an example of using this function to select the first item in the dropdown list? 

 

Thanks so much! 

Link to comment
Share on other sites

If you have the value you could do this I think

 

_WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='MyID']/ul/li[contains(.,'My Selection Value')]")

 

Saludos

Link to comment
Share on other sites

Hi @CaptainBeardsEyesBeard,

could you share a bit of the DOM (reachable by the Browser DevTools as you surely know). It's not necessary to show us the website, but at least a snippet to test and suggest proper answers would be fine. The answer of @Danyfirex is one good way of doing it, but depending on how your website structure (DOM) looks like there could be more matchable ways or something.

Best regards
Sven

Stay innovative!

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)

Link to comment
Share on other sites

@SOLVE-SMART You're right I just share a way to because he did  not share element html.

 

Saludos

Link to comment
Share on other sites

Posted (edited)
21 hours ago, Danyfirex said:

If you have the value you could do this I think

 

_WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='MyID']/ul/li[contains(.,'My Selection Value')]")

 

Saludos

Thanks, I tried this 

_WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="type"]/div/div[1][contains(.,"Male")]')

Now get below in terminal 

_WD_FindElement ==> No match [8] : Parameters:   Strategy=xpath   Selector=//*[@id="type"]/div/div[1][contains(.,"Male")]   StartNodeID=   Multiple=Default   ShadowRoot=Default
_WD_ElementOptionSelect ==> No match [8] : Parameters:    Strategy=xpath    Selector=//*[@id="type"]/div/div[1][contains(.,"Male")]    StartElement=Default

Here's the HTML bit below

image.png.af191e5198ab907a6fe5bab92cfcb840.png

Edited by CaptainBeardsEyesBeard
Link to comment
Share on other sites

Link to comment
Share on other sites

Just as a hint @CaptainBeardsEyesBeard, you can copy parts of the DOM and paste it here (as text).
Then we are able to manipulate any website to have your DOM snippet in it and could properly test the XPath and the _WD_* functions.
But I am sure @Danyfirex can help you in case you follow his/her suggestion 😀 .

And by the way:
Your XPath and your DOM snippet image does not match at all (as far as I can see). No @id="type" visible in the image, no "Male" text visible in the image.
That's why I suggest to post a wider DOM snippet as text (html), like Danyfirex said before.

Best regards
Sven

Edited by SOLVE-SMART

Stay innovative!

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)

Link to comment
Share on other sites

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

  • Recently Browsing   0 members

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