2 | Interacting With Elements | Selenium Python
Вставка
- Опубліковано 20 січ 2025
- 🔥 All Free Tutorials - AutomationStep...
Interacting with Element on a Web page
Find element: element = driver.find_element(By.ID, "element_id")
ID, Name, XPath, TagName, Link_Text, Partial_Link_Text, Class_Name, Css_Selector
Enter text: element.send_keys("Text to enter")
Clear text: element.clear()
Click element: driver.find_element(By.XPATH, "//button[@id='button_id']").click()
Simulate key press: driver.find_element(By.ID, "element_id").send_keys(Keys.RETURN)
How to create XPaths - • Selenium How to create...
----------------------------------------------------------------------
import time
from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
driver.get("google.com")
googleSearchBox = driver.find_element(By.ID, "APjFqb")
googleSearchBox.send_keys("Automation")
googleSearchBox.send_keys(Keys.RETURN)
driver.find_element(By.NAME, "btnK").click()
time.sleep(2)
driver.get("trytestingthis...")
driver.find_element(By.ID, "fname").send_keys("Raghav")
driver.find_element(By.ID, "lname").send_keys("Pal")
time.sleep(2)
driver.find_element(By.XPATH, "//button[@class='btn btn-success1']").click()
time.sleep(2)
▬▬▬▬▬▬▬
Every Like & Subscription gives me great motivation to keep working for you
You can support my mission for education by sharing this knowledge and helping as many people as you can
If my work has helped you, consider helping any animal near you, in any way you can
Never Stop Learning
Raghav Pal
▬▬▬▬ USEFUL LINKS ▬▬▬▬
Ask Raghav - bit.ly/2CoJGWf
Shorts Eng - bit.ly/3H9bifV
Shorts Hindi - bit.ly/3XY7XqN
GitHub Repositories - github.com/Rag...
Udemy - automationstep...
Stories - automationstep...
▬▬ CI | CD | DEVOPS ▬▬
Jenkins Beginner - bit.ly/2MIn8EC
Jenkins Tips & Trick - bit.ly/2LRt6xC
Docker - bit.ly/2MInnzx
Jenkinsfile - bit.ly/3JSMSZ7
Kubernetes - bit.ly/2MJIlMK
Vagrant - bit.ly/3MVKdBt
Ansible - bit.ly/3MUsY3h
▬▬ UI TESTING ▬▬
Selenium Beginners - bit.ly/2MGRS8K
Selenium Java Framework from Scratch - bit.ly/2N9xvR6
Selenium Python - bit.ly/2oyMp5x
Selenium 4 - bit.ly/3AiJOlP
Selenium Tips - bit.ly/2owxc50
Selenium Builder - bit.ly/2MKNtlq
Katalon Studio - bit.ly/2wARFdi
Robot Framework with RIDE- bit.ly/2Px6Ue9
Robot Framework with Eclipse - bit.ly/2N8DZxb
Protractor - bit.ly/2KtqVkU
AccelQ - bit.ly/3PlsAsh
Test Project - bit.ly/2DRNJYE
Cucumber BDD - bit.ly/3Cnno4z
Cypress - bit.ly/3PpEukM
Playwright - bit.ly/3iuPByJ
WebdriverIO - bit.ly/3IJyofA
XPath & Web Locators - bit.ly/3PpEvoQ
▬▬ API TESTING ▬▬
Web Services (API) - bit.ly/2MGafL7
SoapUI - bit.ly/2MGahmd
Postman - bit.ly/2wz8LrW
Postman 2022 - bit.ly/3JWm4qX
Rest Assured - bit.ly/3zUdhRD
Karate API Testing - bit.ly/3w3H5Ku
General - bit.ly/2PYdwmV
JMeter API Testing - bit.ly/3AgVPar
Katalon Studio API Testing - bit.ly/2BwuCTN
API Mocking - bit.ly/3bYPsjS
▬▬ MOBILE TESTING ▬▬
Appium - bit.ly/2ZHFSGX
Mobile Playlist - bit.ly/2PxpeUv
▬▬ PERFORMANCE TESTING ▬▬
JMeter Beginner - bit.ly/2oBbtIU
JMeter Intermediate - bit.ly/2oziNVB
JMeter Advanced - bit.ly/2Q22Y6a
JMeter Tips & Tricks - bit.ly/2NOfWD2
Gatling - bit.ly/3QrWfkV
Performance Testing - bit.ly/2wEXbLS
▬▬ SOURCE CODE MANAGEMENT ▬▬
Git & GitHub - bit.ly/2Q1pagY
GITLAB - bit.ly/2kQPGyQ
▬▬ IDE ▬▬
Eclipse - bit.ly/3AnRhQP
IntelliJ IDEA - bit.ly/3AnyDZ8
Visual Studio Code - bit.ly/2V15yvt
▬▬ PROGRAMMING ▬▬
Java Beginners - bit.ly/2PVUcXs
Java Tips & Tricks - bit.ly/2CdcDnJ
Groovy - bit.ly/2FvWV5C
JavaScript - bit.ly/2KJDZ8o
TypeScript - bit.ly/3dvJBmz
Python - bit.ly/2Z4iRye
Ruby - bit.ly/3JRRmzf
▬▬ BUILD TOOLS ▬▬
Maven - bit.ly/2NJdDRS
Gradle - bit.ly/30l3h1B
▬▬ CLOUD SERVICES ▬▬
Browserstack - bit.ly/3w7kxZn
Saucelabs - bit.ly/3w7kAo1
LambdaTest - bit.ly/3C6TBwM
▬▬ DATA FORMATS ▬▬
JSON - bit.ly/3w450tq
XML - bit.ly/3PqRneH
▬▬ OTHERS ▬▬
Virtualization on Windows - bit.ly/2SItIL9
Mock Interviews - bit.ly/3QGwwVJ
QnA Friday - bit.ly/2NgwGpw
Sunday Special - bit.ly/2wB23BO
Learn how to interact with web elements in Selenium Python
Selenium Python tutorial: Interacting with elements
Mastering Selenium Python with element interaction
-
Such a great teacher you are.Thankyou for your service!
Most welcome
You are amazing. Watching you from Denmark. Thank you for detailed and clear lesson.
You're very welcome
Great, I understand more about what I am doing now, which will let me move from 'assembling code' to 'writing code'. Thanks!
You're welcome Tibby
I have followed the same code, but my code is not able to click on the search bar and enter the word because a sign-in pop-up comes up. What do I do to ignore that and get the search element clicked? Thanks
Roshni
Here’s what you can do step by step:
1. Handle the Pop-up First:
- Use Selenium to detect and close the pop-up.
```python
try:
popup = driver.find_element(By.XPATH, "POPUP_CLOSE_BUTTON_XPATH")
popup.click()
except:
print("No pop-up found.")
```
2. Wait for the Pop-up to Disappear:
- Add an explicit wait to ensure the pop-up is handled.
```python
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 10).until(EC.invisibility_of_element((By.XPATH, "POPUP_XPATH")))
```
3. Click on the Search Bar:
- Now locate the search bar and click.
```python
search_bar = driver.find_element(By.XPATH, "SEARCH_BAR_XPATH")
search_bar.click()
search_bar.send_keys("Your Search Term")
```
4. Retry If Needed:
- If the pop-up reappears, handle it again in a loop.
-
hi @Ragav,
Whenever I am trying to access the google page, a google terms and condition page pops up. how do I deal with that?
Wahidur
There are two ways to deal with the Google terms and conditions page when using Selenium Python:
1. **Click the "Accept" button on the page.**
This is the simplest way to deal with the page, but it requires your script to wait for the page to load and the button to become visible. You can do this using the following code:
```python
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("www.google.com")
# Wait for the terms and conditions page to load
terms_and_conditions_page = driver.find_element_by_id("terms-of-service-link")
# Click the "Accept" button
terms_and_conditions_page.click()
```
2. **Set the `accept_cookies` flag to True.**
This will make Selenium automatically accept the cookies on the terms and conditions page without having to click any buttons. You can do this using the following code:
```python
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("www.google.com")
# Set the "accept_cookies" flag to True
driver.accept_cookies = True
```
Which method you use depends on your specific needs. If you need your script to wait for the terms and conditions page to load and the user to accept the cookies, then you should use the first method. If you need your script to start interacting with the page as soon as possible, then you should use the second method.
**Note:** It is important to note that using the second method will prevent the user from reading and understanding the terms and conditions before accepting them. This may not be ideal for all situations.
Hi Raghav why can't the Button be clicked? even though there was no error message in the terminal and I took the element using selectorhub
could you help me please?
Sofiani
There are a few reasons why a button might not be clickable in Selenium Python, even if there is no error message in the terminal.
* The button might not be visible on the page. This can happen if the button is hidden by another element, or if it is located outside of the viewport.
* The button might not be enabled. This can happen if the button is disabled by the website, or if the user does not have the required permissions to click it.
* The button might not be interactable. This can happen if the button is a decorative element, or if it is not part of the main content of the page.
To troubleshoot this issue, you can try the following:
* Check the visibility of the button. You can use the `is_displayed()` method to check if the button is visible.
* Check the enabled state of the button. You can use the `is_enabled()` method to check if the button is enabled.
* Check the interactability of the button. You can use the `is_interactable()` method to check if the button is interactable.
If the button is visible, enabled, and interactable, then it is possible that there is a problem with the Selenium code that is trying to click the button. You can try debugging the code to find the problem.
Here are some additional things to keep in mind:
* Make sure that you are using the correct locator to find the button.
* Make sure that you are using the correct method to click the button.
* Make sure that you are waiting for the button to be clickable before you try to click it.
I hope this helps
As You always say in video End,
For Us Never Stop Learning, and
For You Never Stop Sharing.. 😊
We Both practice Together and make Each concept clear from scratch - Raghav sir Again Thanks for This Entire Series..🎉
Yes, you are right Prasanna
When I try to execute the automation,the google sign-in page appear.And I can't locate the element of 'stay sign out' button;I got error.pls help me
Can try this:
1. Locating the Element:
- To find and click the "Not Now" button, you can use the following XPath:
```python
driver.find_element_by_xpath("//button[text()='Not Now']").click()
```
- However, keep in mind that the element might be dynamic, so it's essential to wait for it to become clickable. You can use WebDriverWait along with Expected Conditions:
```python
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
# Wait for the element to be clickable
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//div//button[text()='Not Now']"))).click()
```
2. Alternative Approaches:
- Sometimes, the "Sign Out" link may not be directly accessible. In such cases, try clicking on the username first (if visible) to reveal the logout button:
```python
# Click on the username (assuming it reveals the logout button)
driver.find_element_by_xpath("//div[@id='userNavButton']/span").click()
# Now click on the logout button
driver.find_element_by_xpath("//a[contains(text(),'Logout')]").click()
```
3. Documentation and Learning:
- For more scenarios and detailed documentation, explore the Selenium documentation and community resources. You can find relevant discussions on platforms like Stack Overflow and GeeksforGeeks.
- Remember to adapt these solutions to your specific use case, considering any variations in your application's structure.
..
I'm having an error importing By. The error says "Import By could not be resolved."
Leoniel
The error message "Import By could not be resolved" means that the `By` module is not installed in your Python environment. The `By` module is a part of the Selenium library
I hope you have installed Selenium in your project, can check the part 1 video
Then add import statement to import By library in your code
from selenium.webdriver.common.by import By
Hi Raghav, I keep getting this error when try to execute the code for clicking on google search button
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
Hazem
The error message "element not interactable" means that the element you are trying to click on is not in a state where it can be interacted with. This can happen for a variety of reasons, such as:
* The element is hidden.
* The element is disabled.
* The element is not yet loaded.
To fix this error, you need to make sure that the element is in a state where it can be interacted with. Here are some specific things you can do:
* Check the CSS properties of the element to make sure that it is not hidden.
* Check the HTML markup of the element to make sure that it is not disabled.
* Use a wait statement to wait until the element is loaded.
Here is an example of how you can use a wait statement to wait until the element is loaded:
```python
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('www.google.com')
search_button = driver.find_element_by_id('search_button')
wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable(search_button))
search_button.click()
```
This code will wait for up to 10 seconds for the search button to be clickable. If the search button is not clickable after 10 seconds, an error will be raised.
I hope this helps
Practicing the file will be there is no such driver by url telling what can I do sir I have windows 7
Hi Satish
The error message "No such driver by url" means that Selenium cannot find the driver that you are trying to use. This can happen for a few reasons:
* You may not have installed the driver correctly.
* The driver may not be compatible with your version of Selenium.
* The driver may not be compatible with your operating system.
If you are using Windows 7, you need to make sure that you have installed the correct version of the ChromeDriver for Windows 7. You can download the ChromeDriver from the ChromeDriver website: chromedriver.chromium.org/downloads.
Once you have downloaded the ChromeDriver, you need to extract the zip file and save the executable file to a location on your computer. Then, you need to update the path to the ChromeDriver in your Selenium code.
Here is an example of how to update the path to the ChromeDriver in your Selenium code:
```python
from selenium import webdriver
driver = webdriver.Chrome(executable_path="C:\Program Files (x86)\chromedriver.exe")
```
Once you have updated the path to the ChromeDriver, you should be able to run your Selenium code without any errors.
If you are still getting the error message "No such driver by url", you can try the following:
* Check the version of Selenium that you are using. You need to make sure that you are using a version of Selenium that is compatible with the driver that you are trying to use.
* Check the operating system that you are using. You need to make sure that you are using a driver that is compatible with your operating system.
* Try a different driver. There are other drivers available for Selenium, such as the FirefoxDriver and the EdgeDriver. You can try using a different driver if you are still getting the error message "No such driver by url".
I hope this helps
How do i pass the current chrome version to avoid selenium picking chrome 115? thank you
Wangare
To pass the current Chrome version to avoid Selenium picking Chrome 115, you can use the `desired_capabilities` parameter when you create a new Selenium WebDriver instance. The `desired_capabilities` parameter is a dictionary that allows you to specify the desired capabilities of the browser that you want to use.
To pass the current Chrome version, you can add the `chrome_version` key to the `desired_capabilities` dictionary and set the value to the current Chrome version. For example, if the current Chrome version is 100, you would use the following code:
```python
from selenium import webdriver
chrome_version = "100"
desired_capabilities = {
"chrome_version": chrome_version,
}
browser = webdriver.Chrome(desired_capabilities=desired_capabilities)
```
This will create a new Chrome WebDriver instance that uses Chrome 100.
You can also use the `executable_path` parameter to specify the path to the Chrome executable file. This can be useful if you want to use a specific version of Chrome that is not installed on your system. For example, to use Chrome 99, you would use the following code:
```python
from selenium import webdriver
chrome_version = "99"
executable_path = f"/path/to/chrome-{chrome_version}.exe"
desired_capabilities = {
"chrome_version": chrome_version,
}
browser = webdriver.Chrome(executable_path=executable_path, desired_capabilities=desired_capabilities)
```
This will create a new Chrome WebDriver instance that uses Chrome 99.
I hope this helps
Is dirver. close() is necessary?
In Selenium, `driver.close()` is a method that closes the current window or tab of the browser instance. This method does not quit the entire browser session, but rather closes the current window or tab, allowing you to continue interacting with the browser instance if there are other windows or tabs open.
On the other hand, `driver.quit()` is a method that quits the entire browser session, closing all windows and tabs, and shutting down the WebDriver service.
When is `driver.close()` necessary?
`driver.close()` is necessary in the following scenarios:
1. Multiple windows or tabs: If your test opens multiple windows or tabs, you might want to close each window or tab individually using `driver.close()` to ensure that the test doesn't interfere with other tests or leave unnecessary windows open
2. Resource management: Closing unnecessary windows or tabs can help manage system resources, especially when running tests in a resource-constrained environment
3. Test isolation: Closing the current window or tab can help isolate each test, ensuring that the next test starts with a clean slate
When can `driver.close()` be skipped?
`driver.close()` can be skipped in the following scenarios:
1. Single window or tab: If your test only opens a single window or tab, you can skip `driver.close()` and use `driver.quit()` to close the entire browser session
2. Implicit cleanup: Many test frameworks, such as Pytest or Unittest, provide implicit cleanup mechanisms that automatically close the browser instance after each test. In such cases, `driver.close()` might not be necessary
Best practice
As a best practice, it's recommended to use `driver.quit()` instead of `driver.close()` whenever possible. `driver.quit()` ensures that the entire browser session is closed, which can help prevent resource leaks and ensure a clean test environment.
However, if you need to close individual windows or tabs, `driver.close()` can be useful. Just remember to use `driver.quit()` eventually to close the entire browser session
..
I tried with other sites as well other than google still google page is opening.
will need to check more details Roshni
Hi! I'm not able to pass line 11 of your code even if y copy and paste, could you help me? Thanks
will need more details Mario, pls give me timestamp and more details
@@RaghavPal hi! Thanks for your response, I have already solved the issue
Thank you for the knowledge Sir!
How do we find a word/text say for example "India is my country" in a webpage and double-click on it?
Note: Chrome is already opened.
Praveen
Here's how to find a word/text in a webpage and double-click on it using Selenium Python:
```python
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
# Locate the text using appropriate strategy
text_to_find = "India is my country"
text_element = driver.find_element(By.XPATH, f"//body//*[contains(text(), '{text_to_find}')]")
# Double click on the text element
actions = ActionChains(driver)
actions.double_click(text_element).perform()
```
This code performs the following steps:
1. **Imports necessary libraries:**
- `selenium.webdriver`: Provides the WebDriver class for browser automation.
- `selenium.webdriver.common.by`: Defines methods for locating elements on the webpage.
- `selenium.webdriver.common.action_chains`: Provides classes for performing complex mouse and keyboard interactions.
2. **Defines the text to find:** Replace "India is my country" with your desired text.
3. **Locates the text element:**
- Uses By.XPATH with a wildcard search for any element containing the specified text.
- You can adjust the locator strategy based on your specific HTML structure.
4. **Creates an ActionChains object:** Allows you to chain multiple actions together.
5. **Double-clicks on the text element:** Uses the `double_click` method and performs the action.
This example assumes Chrome is already opened and the relevant webpage is loaded. You need to replace `driver` with your actual browser instance obtained using `webdriver.Chrome()` or other relevant browser driver.
**Alternative locators:**
- `By.CSS_SELECTOR`: You can use CSS selectors to locate the element, assuming the text has a specific identifier or class.
- `By.ID`: If the text element has a unique ID, you can use `By.ID` for faster identification.
**Additional tips:**
- Use explicit waits to ensure the element is visible before interacting with it.
- Consider using regular expressions for more flexible text matching.
- You can modify the code to handle multiple occurrences of the text and double-click on a specific one.
By adapting this code and adjusting the locators based on your specific webpage structure, you can effectively find and double-click on any text element using Selenium Python.
Thank you for an amazing tutorial.
Can you guide how to access buttons inside the dropdown menu and gets enabled when the dropdown
Arooj
To access buttons inside a dropdown menu in Selenium Python, you can use the following steps:
1. Locate the dropdown menu element. You can use the `find_element_by_css_selector()` or `find_element_by_xpath()` method to locate the dropdown menu element by its CSS selector or XPath.
2. Click on the dropdown menu element. You can use the `click()` method to click on the dropdown menu element.
3. Wait for the dropdown menu to open. You can use the `implicitly_wait()` method to wait for the dropdown menu to open.
4. Locate the buttons inside the dropdown menu. You can use the `find_elements_by_css_selector()` or `find_elements_by_xpath()` method to locate the buttons inside the dropdown menu by their CSS selector or XPath.
5. Interact with the buttons inside the dropdown menu. You can use the `click()`, `is_enabled()`, and other methods to interact with the buttons inside the dropdown menu.
Here is an example of a Selenium Python script that accesses buttons inside a dropdown menu:
```python
from selenium import webdriver
driver = webdriver.Chrome()
# Locate the dropdown menu element.
dropdown_menu = driver.find_element_by_css_selector(".dropdown-menu")
# Click on the dropdown menu element.
dropdown_menu.click()
# Wait for the dropdown menu to open.
driver.implicitly_wait(10)
# Locate the buttons inside the dropdown menu.
buttons = driver.find_elements_by_css_selector(".dropdown-item")
# Interact with the buttons inside the dropdown menu.
for button in buttons:
if button.is_enabled():
button.click()
# Close the browser.
driver.quit()
```
You can modify this script to automate the specific dropdown menu that you are working with.
Here are some additional tips for automating dropdown menus in Selenium Python:
* Use the `Select` class to select options from a dropdown menu. The `Select` class provides a number of methods for selecting options from a dropdown menu, such as `select_by_visible_text()`, `select_by_value()`, and `select_by_index()`.
* Use the `Actions` class to interact with dropdown menus in a more complex way. For example, you can use the `Actions` class to hover over a dropdown menu and click on an option.
* Use a third-party library to automate dropdown menus. There are a number of third-party libraries that can help you automate dropdown menus, such as the `SeleniumExtras` library.
I hope this helps!
hi @Ragav,
could you give code for dropdown selection, for multi-select and single select for the same example.
Hi Prashanth
Here is the code for dropdown selection, for multi-select and single select for the same example:
```python
from selenium import webdriver
from selenium.webdriver.common.by import By
def select_option_by_index(driver, element_id, index):
driver.find_element(By.ID, element_id).select_by_index(index)
def select_option_by_value(driver, element_id, value):
driver.find_element(By.ID, element_id).select_by_value(value)
def select_option_by_visible_text(driver, element_id, text):
driver.find_element(By.ID, element_id).select_by_visible_text(text)
def main():
driver = webdriver.Chrome()
driver.get("www.w3schools.com/tags/tryit.asp?filename=tryhtml_select_multiple")
# Select option by index
select_option_by_index(driver, "cars", 2)
# Select option by value
select_option_by_value(driver, "cars", "Volvo")
# Select option by visible text
select_option_by_visible_text(driver, "cars", "BMW")
driver.quit()
if __name__ == "__main__":
main()
```
This code will open the W3Schools website and select the options in the "cars" dropdown list by index, value, and visible text.
To run the code, you can save it as a Python file and then run it from the command line. For example, if you save the code as `dropdown_selection.py`, you can run it by typing the following command into the command line:
```
python dropdown_selection.py
```
This will run the code and open the W3Schools website. The dropdown list will be populated with the options "Volvo", "BMW", and "Audi". The option "BMW" will be selected by default. You can then select the other options by index, value, or visible text.
I hope this helps
how to interact in pseudo-elements? ::after
need more details on this..
could you tell me how to do this code in google colab
Have not tried this Shelin
Great Work.. Thanks
You are welcome Islam
@Raghav Sir - Getting below mentioned error while clicking on Google Search button.
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
Could you please help me out on this?
Hi Ankur
Sure, I can help you with that. The error message "selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable" means that the element that you are trying to interact with is not interactable. This can happen for a number of reasons, including:
* The element is not visible.
* The element is disabled.
* The element is hidden.
To troubleshoot this error, you can try the following:
* Make sure that the element is visible. You can do this by checking the visibility of the element using the `is_displayed()` method.
* Make sure that the element is enabled. You can do this by checking the enabled state of the element using the `is_enabled()` method.
* Make sure that the element is not hidden. You can do this by checking the visibility of the element's parent element.
If you have checked all of these things and you are still getting the `ElementNotInteractableException` exception, you can try posting a question on the Selenium forum or mailing list. There are a number of experienced Selenium users who can help you troubleshoot the error.
Here is an example of how to check the visibility of an element using the `is_displayed()` method:
```python
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("www.google.com")
search_box = driver.find_element_by_id("search")
if search_box.is_displayed():
print("The search box is visible.")
else:
print("The search box is not visible.")
```
Here is an example of how to check the enabled state of an element using the `is_enabled()` method:
```python
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("www.google.com")
search_box = driver.find_element_by_id("search")
if search_box.is_enabled():
print("The search box is enabled.")
else:
print("The search box is not enabled.")
```
I hope this helps
Raghav what is the schedule for the upcoming videos
and thank you for this great tutorial
I will add new videos every week
great sir please cover all topics related to python selenium and thanks for starting series
Sure I will
Again great work..
Thanks
Thanks for sharing.
Most welcome
Thank you
Most welcome
Good
Thanks Lalitesh
Hello Sir
Hi Hemant