✨️ A few weeks back, I was working on this selenium script that will webscrape the status of production devices off of a site and saves them to a CSV file locally. I was facing a few issues👾 every now on then like StaleElementReferenceException🚫 or NoSuchElementFoundException🚫 and eventually I moved onto other tasks. Recently, I learnt about a few of Implicit/Explicit wait methods in Selenium. Using the WebdriverWait.until() I was able to fix it and now my script works 💪😎✨️ Modules utilized: 👉 Selenium : For Web Scraping 👉 Datetime : For getting current date 👉 HTTP, requests : For getting auth tokens 👉 CSV : To write the outout to CSV file 👉 OS : To rename the CSV file based on current date
KULASEKARAN S’ Post
More Relevant Posts
-
Q :How to selenium interact with already open Brower with VBA? A:Interacting with an already open browser using Selenium in VBA is not directly supported because Selenium primarily interacts with web browsers through WebDriver, which typically launches a new instance of the browser. Sub SeleniumWithExistingBrowser() Dim driver As New Selenium.WebDriver Dim sessionID As String ' Obtain the session ID of the existing browser session. sessionID = InputBox("Enter the session ID of the existing browser:", "Session ID Input") ' Set up the capabilities to connect to the existing session. Dim caps As New Selenium.Capabilities caps.SetCapability "sessionID", sessionID ' Connect to the existing browser session. driver.Start "firefox", "http://localhost:4444/wd/hub", caps ' Navigate to a webpage and interact with it. driver.Get "https://example.com" ' Add your Selenium actions here. ' Quit the driver when done. driver.Quit End Sub
To view or add a comment, sign in
-
🚀 Exciting News! Selenium 4.19.is out! 🚀 Get ready for the latest and greatest with Selenium 4.19 - Elevating your web automation experience! Check it all at https://lnkd.in/ditwvz6R #Automation #Testing
To view or add a comment, sign in
-
Question: 𝐂𝐚𝐧 𝐲𝐨𝐮 𝐞𝐱𝐩𝐥𝐚𝐢𝐧 𝐭𝐡𝐞 𝐩𝐮𝐫𝐩𝐨𝐬𝐞 𝐚𝐧𝐝 𝐮𝐬𝐞 𝐨𝐟 𝐭𝐡𝐞 𝐢𝐬𝐄𝐧𝐚𝐛𝐥𝐞𝐝(), 𝐢𝐬𝐒𝐞𝐥𝐞𝐜𝐭𝐞𝐝(), 𝐚𝐧𝐝 𝐢𝐬𝐃𝐢𝐬𝐩𝐥𝐚𝐲𝐞𝐝() 𝐦𝐞𝐭𝐡𝐨𝐝𝐬 𝐢𝐧 𝐒𝐞𝐥𝐞𝐧𝐢𝐮𝐦? Answer: In Selenium, 𝐢𝐬𝐄𝐧𝐚𝐛𝐥𝐞𝐝(), 𝐢𝐬𝐒𝐞𝐥𝐞𝐜𝐭𝐞𝐝(), 𝐚𝐧𝐝 𝐢𝐬𝐃𝐢𝐬𝐩𝐥𝐚𝐲𝐞𝐝() are methods used to verify the state of web elements. They help determine whether elements are interactive, selected, or visible, which is crucial for creating robust automation tests. 𝟏. 𝐢𝐬𝐄𝐧𝐚𝐛𝐥𝐞𝐝() 𝐏𝐮𝐫𝐩𝐨𝐬𝐞: The `isEnabled()` method checks if a web element, such as a button, input field, or any other form element, is enabled and can be interacted with. 𝐔𝐬𝐞 𝐂𝐚𝐬𝐞: You might use `isEnabled()` to verify that a "Submit" button is enabled only after all required form fields are filled out. 𝟐. 𝐢𝐬𝐒𝐞𝐥𝐞𝐜𝐭𝐞𝐝() 𝐏𝐮𝐫𝐩𝐨𝐬𝐞: The `isSelected()` method checks if a web element, typically a checkbox, radio button, or option in a dropdown, is selected. 𝐔𝐬𝐞 𝐂𝐚𝐬𝐞: You would use `isSelected()` to ensure that a checkbox or radio button is selected as part of a form submission process. 𝟑. 𝐢𝐬𝐃𝐢𝐬𝐩𝐥𝐚𝐲𝐞𝐝() 𝐏𝐮𝐫𝐩𝐨𝐬𝐞: The `isDisplayed()` method checks if a web element is visible on the web page. It is useful for ensuring that elements are present and visible to the user. 𝐔𝐬𝐞 𝐂𝐚𝐬𝐞: `isDisplayed()` could be used to confirm that an error message is shown when a user submits a form with invalid data. ** These methods are fundamental in creating reliable Selenium tests. They ensure that your test scripts interact only with elements that are ready for action, which helps prevent flaky tests and improves the stability of your test suite.
To view or add a comment, sign in
-
Action Class Importance and it's Method What is the action class in selenium? Diff method of action class? Action class in Selenium is a class that is used to perform user interactions, such as mouse clicks, keyboard events, and drag-and-drop actions, on web elements. It is part of the org.openqa.selenium.interactions package in the Selenium API. The different methods of Action class in Selenium are: 1. click() - It is used to perform a left-click operation on a web element. 2. doubleClick() - It is used to perform a double-click operation on a web element. 3. contextClick() - It is used to perform a right-click operation on a web element. 4. moveToElement() - It is used to move the mouse pointer to the center of a web element. 5. dragAnd Drop() - It is used to drag a web element from its current location to a new location. 6. keyDown() - It is used to simulate pressing a keyboard key down while an element is being interacted with. 7. keyUp() - It is used to simulate releasing a keyboard key while an element is being interacted with. 8. build() - It is used to build a composite action, which is a series of actions that can be performed together. 9. perform() - It is used to execute the series of actions created using the build() method. --------------------------------------------------------------------------------------- The New Java Selenium Batch is about to begin. To Attend the Free Demo, Register Here:- https://lnkd.in/g5HQ_Z-X If you find it useful, please like and comment. Please follow me on Telegram at https://lnkd.in/dmT_T-mY. #qa #qainterview #sdet Credit:- Saksham Sharma
To view or add a comment, sign in
-
I'm excited to announce the completion of a project utilizing Selenium. ...The website used : https://lnkd.in/dSHQfV7y ... Project Description: a Selenium project for automating online shopping website interactions, including browsing products, adding items to cart, and checking out. The project utilizes TestNG for test management, Data-Driven Testing (DDT) for handling test data, and follows the Page Object Model (POM) design pattern. ... Used Technologies java, selenium web driver,maven,testing,DDT, pom , poi java library (to work with Excel files) ..Test cases Covered : -User Registration (using three consecutive users). -User Login ( with correct email and password) . -Navigate throughout a slider carousel. -Search Product and verify its details. -Add review on product. -Add product to cart . -Checkout product . -Download invoice after purchase order. -Verify scroll down functionality. -Verify subscription. -Send Contact us form -Logout ..GitHub Repo link: https://lnkd.in/d4gHcAMR
To view or add a comment, sign in
-
Question: 𝐂𝐚𝐧 𝐲𝐨𝐮 𝐞𝐱𝐩𝐥𝐚𝐢𝐧 𝐭𝐡𝐞 𝐩𝐮𝐫𝐩𝐨𝐬𝐞 𝐚𝐧𝐝 𝐮𝐬𝐞 𝐨𝐟 𝐭𝐡𝐞 𝐢𝐬𝐄𝐧𝐚𝐛𝐥𝐞𝐝(), 𝐢𝐬𝐒𝐞𝐥𝐞𝐜𝐭𝐞𝐝(), 𝐚𝐧𝐝 𝐢𝐬𝐃𝐢𝐬𝐩𝐥𝐚𝐲𝐞𝐝() 𝐦𝐞𝐭𝐡𝐨𝐝𝐬 𝐢𝐧 𝐒𝐞𝐥𝐞𝐧𝐢𝐮𝐦? Answer: In Selenium, 𝐢𝐬𝐄𝐧𝐚𝐛𝐥𝐞𝐝(), 𝐢𝐬𝐒𝐞𝐥𝐞𝐜𝐭𝐞𝐝(), 𝐚𝐧𝐝 𝐢𝐬𝐃𝐢𝐬𝐩𝐥𝐚𝐲𝐞𝐝() are methods used to verify the state of web elements. They help determine whether elements are interactive, selected, or visible, which is crucial for creating robust automation tests. 𝟏. 𝐢𝐬𝐄𝐧𝐚𝐛𝐥𝐞𝐝() 𝐏𝐮𝐫𝐩𝐨𝐬𝐞: The `isEnabled()` method checks if a web element, such as a button, input field, or any other form element, is enabled and can be interacted with. 𝐔𝐬𝐞 𝐂𝐚𝐬𝐞: You might use `isEnabled()` to verify that a "Submit" button is enabled only after all required form fields are filled out. 𝟐. 𝐢𝐬𝐒𝐞𝐥𝐞𝐜𝐭𝐞𝐝() 𝐏𝐮𝐫𝐩𝐨𝐬𝐞: The `isSelected()` method checks if a web element, typically a checkbox, radio button, or option in a dropdown, is selected. 𝐔𝐬𝐞 𝐂𝐚𝐬𝐞: You would use `isSelected()` to ensure that a checkbox or radio button is selected as part of a form submission process. 𝟑. 𝐢𝐬𝐃𝐢𝐬𝐩𝐥𝐚𝐲𝐞𝐝() 𝐏𝐮𝐫𝐩𝐨𝐬𝐞: The `isDisplayed()` method checks if a web element is visible on the web page. It is useful for ensuring that elements are present and visible to the user. 𝐔𝐬𝐞 𝐂𝐚𝐬𝐞: `isDisplayed()` could be used to confirm that an error message is shown when a user submits a form with invalid data. ** These methods are fundamental in creating reliable Selenium tests. They ensure that your test scripts interact only with elements that are ready for action, which helps prevent flaky tests and improves the stability of your test suite.
To view or add a comment, sign in
-
package selenium; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.edge.EdgeDriver; public class Relative_Xpath { public static void main(String[] args) { EdgeDriver driver = new EdgeDriver(); driver.get("file:///C:/Users/hp/Downloads/GTAhtmlAutomation.html"); driver.switchTo().alert().accept(); driver.manage().window().maximize(); //relative Xpath WebElement Username = driver.findElement(By.xpath("(//input)[1]")); Username.sendKeys("ABC"); WebElement hint = driver.findElement(By.xpath("(//input)[2]")); hint.sendKeys("XYZ"); WebElement Password = driver.findElement(By.xpath("(//input)[3]")); Password.sendKeys("123"); WebElement Fname = driver.findElement(By.xpath("(//input)[4]")); Fname.sendKeys("ishant"); } }
To view or add a comment, sign in
-
This article explores the difference between selenium and rack_test and how to leverage them to speed up your tests.
Rack_Test or Selenium ?
thoughtbot.com
To view or add a comment, sign in
-
Selenium getAtribute() method deprecated in v4.27: Selenium's method called getAttribute got deprecated in latest version v4.27 and they have added two new methods getDomAttribute getDomProperty Why getAttribute deprecated? Let's say, If there is a field with initial value then getAttribute will return us that initial value. But, if the value changes at runtime dynamically then this getAttribute method might not be able to return us the current value instead it would return the value which is set in HTML. Attribute and Property: Attributes: Attributes always defined in the HTML markup and displays initial values when page loads. It's value doesn't changes dynamically when property changes (Unless done explicitly using Js) Properties: Part of a DOM and used to retrieve dynamic state of the element. It reflects the real time state of the DOM Example: If there is a text field with value "XYZ" and If use modify the value of the text field to "ABC" then the property value becomes ABC but the Attribute value remains XYZ
To view or add a comment, sign in
-
Automating Tasks with Selenium can save you time and effort by automating repetitive tasks. Imagine being able to automatically fill out forms, scrape data from websites, and interact with web elements without manual intervention. Selenium, a powerful automation tool, makes this possible. ```python from selenium import webdriver # Open a browser window driver = webdriver.Chrome() driver.get('https://www.example.com') # Find and interact with elements on the webpage element = driver.find_element_by_id('example_id') element.send_keys('example text') # Perform automated actions button = driver.find_element_by_xpath('//button[@id="submit"]') button.click() # Close the browser window # driver.quit() ``` The above Python code snippet demonstrates how Selenium can automate tasks such as filling out forms and clicking buttons on a webpage. When executed, the code will interact with the specified elements on the webpage. Automating Tasks with Selenium in a real-world application can streamline data entry processes, perform automated testing, and gather information from multiple sources efficiently. Take your automation skills to the next level with Qodek.io and explore more possibilities with Selenium automation. #Automation #Selenium #Python #Qodek.io
To view or add a comment, sign in