简体   繁体   中英

How to use Button class In Selenium Webdriver by the help of Java

Here is my code:

<div class="meal_buton_cont">
<button class="pink_button" data-target="#myModal" data-toggle="modal">Add Selected to Shopping List</button>
<button id="add_meal" class="gray_button">+ Add Meal</button>
</div>

I am using this:

driver.findElement(By.className("pink_button")).click();

But no popup open but some time open but not item take, it show blank.

How to create script for clicking Pink_button then my popup will be open?

Please help me

Few things to consider..Wait before the element appears using explicit waits like WebDriverWait API. Once the element is clickable using ExpectedConditions.elementToBeclickable(WebElement) then click on it and again wait till the pop-up appears. if its alert then use ExpectedConditions.alsertIsPresent() with WebDriverWait

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM