How can I write ‘a:hover’ in inline CSS?

Short answer: you can’t. Long answer: you shouldn’t. Give it a class name or an id and use stylesheets to apply the style. :hover is a pseudo-selector and, for CSS, only has meaning within the style sheet. There isn’t any inline-style equivalent (as it isn’t defining the selection criteria). Response to the OP’s comments: See … Read more

Checking if an element exists with Python Selenium

For a): from selenium.common.exceptions import NoSuchElementException def check_exists_by_xpath(xpath): try: webdriver.find_element_by_xpath(xpath) except NoSuchElementException: return False return True For b): Moreover, you can take the XPath expression as a standard throughout all your scripts and create functions as above mentions for universal use. I recommend to use CSS selectors. I recommend not to mix/use “by id”, “by … Read more

How to make a stable two column layout in HTML/CSS

Here you go: <html> <head> <title>Cols</title> <style> #left { width: 200px; float: left; } #right { margin-left: 200px; /* Change this to whatever the width of your left column is*/ } .clear { clear: both; } </style> </head> <body> <div id=”container”> <div id=”left”> Hello </div> <div id=”right”> <div style=”background-color: red; height: 10px;”>Hello</div> </div> <div class=”clear”></div> … Read more

Chrome New Tab Page extension steal focus from the address bar

ManifestV3 update This answer is adapted from This has been tested with both Manifest V2 and V3. Tested in Google Chrome 99.0.4844.51 64-bit (Windows 10). Replace the content of focus.js with: if ( !== “?x”) { = “?x”; throw new Error; // load everything on the next page; // stop execution on this … Read more

How can I get text of an element in Selenium WebDriver, without including child element text?

Here’s a general solution: def get_text_excluding_children(driver, element): return driver.execute_script(“”” return jQuery(arguments[0]).contents().filter(function() { return this.nodeType == Node.TEXT_NODE; }).text(); “””, element) The element passed to the function can be something obtained from the find_element…() methods (i.e., it can be a WebElement object). Or if you don’t have jQuery or don’t want to use it, you can replace … Read more

Communication between tabs/windows with same origin [duplicate]

I’m sticking to the shared local data solution mentioned in the question using localStorage. It seems to be the best solution in terms of reliability, performance, and browser compatibility. localStorage is implemented in all modern browsers. The storage event fires when other tabs makes changes to localStorage. This is quite handy for communication purposes. References … Read more

How to place two forms on the same page?

You could make two forms with 2 different actions <form action=”login.php” method=”post”> <input type=”text” name=”user”> <input type=”password” name=”password”> <input type=”submit” value=”Login”> </form> <br /> <form action=”register.php” method=”post”> <input type=”text” name=”user”> <input type=”password” name=”password”> <input type=”submit” value=”Register”> </form> Or do this <form action=”doStuff.php” method=”post”> <input type=”text” name=”user”> <input type=”password” name=”password”> <input type=”hidden” name=”action” value=”login”> <input type=”submit” … Read more