How to create javascript executor to make element visible in selenium webdriver

后端 未结 1 1299
情书的邮戳
情书的邮戳 2021-01-07 07:45

Currently am working on selenium webdriver. I have many drop downs like visualization, Period, Type etc,. In the drop down many options are there. I want to select an option

相关标签:
1条回答
  • 2021-01-07 08:05

    You can try to use the following script to make element visible: document.getElementById('periodId').style.display='block';

    In java code this script can be executed with the following code:

    JavascriptExecutor executor = (JavascriptExecutor)driver;
    executor.executeScript("document.getElementById('periodId').style.display='block';");
    

    If you just want to select an option in drop down you can use the following java code:

    Select select = new Select(driver.findElement(By.id("periodId")));
    select.deselectAll();
    select.selectByVisibleText("Last 4 Weeks");
    
    0 讨论(0)
提交回复
热议问题