0

I have this js code to remove some hidden dropdown element:

//select account from dropdown using javascript val js: JavascriptExecutor = driver.asInstanceOf[JavascriptExecutor] js.executeScript("$('.select-upload_company_id>.center').html(" + invoice.companyNumber + ")") //visible one val cmd: String = "$('#company_id option[value=\"" + invoice.companyNumber + "\"]').eq(1).attr('selected','selected')" //hidden js.executeScript(cmd) 

currently its selecting by value, but I want to select by visible text....how do I do that here? what do I need to change in this code?

thanks

    1 Answer 1

    0

    You can use "contains" selector for selecting option by text.

    Example selector:

     $('#company_id option:contains(\"" + invoice.companyNumber + "\")'); 

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.