-
Hi, I'm new to SeleniumBase and I'm trying to automate a specific action. I don't understand much despite the documentation... I've managed to do what I wanted in terms of user actions, but now I'd like to hide a popup when a site opens. However, in spite of numerous attempts, it's impossible to retrieve the element with the CSS classes to hide it... Thanks in advance for your help
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
Hello! Here's a sample script that hides various elements on a web page using the from seleniumbase import SB
with SB() as sb:
sb.open("https://fr.wikipedia.org/wiki/Tour_Eiffel")
sb.sleep(1)
sb.hide_elements("div#siteNotice")
sb.sleep(1)
sb.hide_elements("nav#mw-panel-toc")
sb.sleep(1)
sb.hide_elements('img[src*="Tour_Eiffel_Wikimedia"]')
sb.sleep(2) To hide only the first matching selector found, use For the full French experience, here's a SeleniumBase example using the French Language API: (Adds from seleniumbase.translate.french import CasDeBase
CasDeBase.main(__name__, __file__, "--demo")
class MaClasseDeTest(CasDeBase):
def test_exemple_1(self):
self.ouvrir("https://fr.wikipedia.org/wiki/")
self.vérifier_texte("Wikipédia")
self.vérifier_élément('[alt="Wikipédia"]')
self.js_taper("#searchform input", "Crème brûlée")
self.cliquer("#searchform button")
self.vérifier_texte("Crème brûlée", "#firstHeading")
self.vérifier_élément('img[alt*="Crème brûlée"]')
self.js_taper("#searchform input", "Jardin des Tuileries")
self.cliquer("#searchform button")
self.vérifier_texte("Jardin des Tuileries", "#firstHeading")
self.vérifier_élément('img[alt*="Jardin des Tuileries"]')
self.retour()
self.vérifier_url_contient("brûlée")
self.en_avant()
self.vérifier_url_contient("Jardin") Translations can be found in SeleniumBase/examples/translations. All methods can be found here: SeleniumBase/help_docs/method_summary.md. (The See SeleniumBase/examples for all examples. |
Beta Was this translation helpful? Give feedback.
Hello! Here's a sample script that hides various elements on a web page using the
SB()
format that has more methods than theDriver()
format: (sleep()
added so that you have time to see the difference).To hide only the first matching selector found, use
hide_element(selector)
instead ofhide_elements(selector)
.For the full French experience, here's a SeleniumBase example using the French…