'How to click multiple 'Add to cart' button from product list using Selenium and Python?
I am able to add single and all available items, but not sure how to add multiple items
Solution 1:[1]
Remove unnecessary element from items using methods items.remove(), items.pop(), del items[].
Solution 2:[2]
If you are using Bootstrap-5 then don't need to write CSS for text or element alignment so you need to use pre-defined classes from BS-5.
You just need to add me-auto class in <span> or <label> then text will render from left side.
Helpful like:
https://getbootstrap.com/docs/5.1/utilities/flex/
https://css-tricks.com/how-auto-margins-work-in-flexbox/
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary m-5" data-bs-toggle="modal" data-bs-target="#exampleModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<span class="me-auto">Example vertically aligned text</span>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save</button>
</div>
</div>
</div>
</div>
Solution 3:[3]
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#inputInv">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="inputInv" tabindex="-1" aria-labelledby="InputInventory" aria-hidden="true" data-bs-backdrop="static">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="InputInventory">INPUT DATA</h5>
</div>
<div class="modal-body">
<!-- CONTENT HERE -->
</div>
<div class="modal-footer">
<div class="flex-grow-1 bd-highlight">Example vertically aligned text</div>
<div class="bd-highlight"><button id="btnInClose" type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Close</button></div>
<div class="bd-highlight"><button id="btnInSave" type="button" class="btn btn-sm btn-primary">Save</button></div>
</div>
</div>
</div>
</div>
I think This would fix your problem
Just added the buttons and the text into the div elements and added class bd-highlight to the three div elements
Also added class flex-grow-1 to the text div element
Solution 4:[4]
Simply use the justify-content-between class on the modal-footer...
<!-- Modal -->
<div class="modal fade" id="inputInv" tabindex="-1" aria-labelledby="InputInventory" aria-hidden="true" data-bs-backdrop="static">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="InputInventory">INPUT DATA</h5>
</div>
<div class="modal-body">
<!-- CONTENT HERE -->
</div>
<div class="modal-footer justify-content-between">
<div>
<span>Example vertically aligned text</span>
</div>
<div class="actions">
<button id="btnInClose" type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Close</button>
<button id="btnInSave" type="button" class="btn btn-sm btn-primary">Save</button>
</div>
</div>
</div>
</div>
</div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Сергей Кох |
| Solution 2 | Raeesh Alam |
| Solution 3 | |
| Solution 4 | Zim |
