How to select an option from dropdown select? (Puppeter)

image

Am i able to select any of those with openbullet2 puppeter?

Yes there are blocks to select by value, index etc.

Emh, how should i do it in like this?

<select data-ng-model="model.data._year" name="user.identity.dateOfBirth.date_year" id="_useridentitydateOfBirthdate_year" class="form-control ng-pristine ng-valid ng-empty ng-touched" data-ng-change="model.TryParse()" data-ng-disabled="model.data.Disabled" style="">
            <option value="" label=" " selected="selected"></option>
            <!-- ngRepeat: year in model.dateOptions.years --><option data-ng-repeat="year in model.dateOptions.years" value="2014" class="ng-binding ng-scope" style="">
                2014
            </option><!-- end ngRepeat: year in model.dateOptions.years --><option data-ng-repeat="year in model.dateOptions.years" value="2013" class="ng-binding ng-scope">
                2013
      Like, if i wanted to select 2013...

Ofc there are a lot of years below, like 2003, 1990, etc

You have to target the select element and then select by value or index (there are dedicated blocks for it)

Tried it rq but…
image

could you give me an example using that code? i honestly have no idea on how to do it.

That’s how you’re supposed to do it. Are you sure the element is visible on the page as soon as the block is executed? Maybe use a wait for element block first to make sure it’s there. Otherwise learn some js and do it from the execute js block directly.

I mean, it opens the thing, but i gotta input the specific year using input.YEAR (From the wordlist i created, Or however i’m able to.)
But it won’t let me input it anywhere.

Also tried JS, but i got errors.
Compressed code for OB:
async function start(){page.select(’_useridentitydateOfBirthdate_year’,’<input.YEAR>’)}(async function(){const response=await start()})();

async function start() {
   page.select('_useridentitydateOfBirthdate_year', '<input.YEAR>')
}

(async function() {
    const response = await start()
})();

But i can’t get it to work, do you have any template for this specific JS function?

It should be something like this

immagine

Should i make a translator function that translates the year to the index value?

No you can select directly by text or by value, there are blocks for it.

If you want to use the js snippet you need to make sure you are using interpolated mode

immagine

And you need to make sure you’re calling the functions you defined, I don’t know if it calls them automatically like that.

Thank you ruri!
That worked!

Ahh, i just bumped into an aerror, i need more than 1 of these blocks and got this:
EvaluationFailedException: Evaluation failed: SyntaxError: Identifier ‘el’ has already been declared
I’m using different identifiers though.

image
image
image

image

Oh I guess this is a bug in OB2, open an issue I will try to prioritize it. Sorry about it

Alrighty, i will.
thank ya for your time

1 Like

I’d be happy to find a workaround for you if you wanna send me the config
I.e. clicking it by pixel values, or TAB or injecting JavaScript code into the page

I wanna keep this config as private as possible, sorry!
Still, ruri, don’t you know a way to do this in JS so i can have this done rn?
i’ve tried js before but my code didn’t work.

1 Like

Totally understand! <3
Try making it press TAB enough times to select the correct values and put some logic into it if you need

1 Like

That’d be too hard for me haha, i barely even know JS, i couldn’t make a complete function even if my life was at the line

1 Like