packersmovers

Members Login
Username 
 
Password 
    Remember Me  

Topic: Selenium with Python 3 - How to click on element

Post Info
Member
Status: Offline
Posts: 5
Date:
Selenium with Python 3 - How to click on element
Permalink  
 

I am new to Selenium I have been following the documentations but they seem outdated.

(for curious people, that is the admin section of Atlassian's Cloud https://admin.atlassian.com/s/orgID/users/userID, I wish to remove site access for multiple users)

Here is a subset of the HTML page:

<div class = "sc-bSbAYC kOjfgA">
  <label data-size="regular" class="css-ji2l50">
    <input name="" type="checkbox" value="123456789abcde">
    <span ...</span>
  </label>
</div>

I want to capture and click on <input name="" type="checkbox" value="123456789abcde">

Since there is no element = driver.find_element(By.VALUE,"123456789abcde") (link to the documentationskytvwhatsapp
I am using element = driver.find_element(By.XPATH, "//input[@value='123456789abcde']")

This seems to work fine, print(element) gives <selenium.webdriver.remote.webelement.WebElement (session="b2d92d7e20334085b7989c009fa77785", element="c23fdd99-9052-4028-9a72-e8f39873c720")>

But element.click() results in a ElementClickInterceptedException exception. element.click does return <bound method WebElement.click of <selenium.webdriver.remote.webelement.WebElement (session="b2d92d7e20334085b7989c009fa77785", element="c23fdd99-9052-4028-9a72-e8f39873c720")>> but the button is not toggled.



__________________
O noizados também são compatíveis com conteúdo 4K e HD.
Member
Status: Offline
Posts: 16
Date:
Permalink  
 

I like your all post. You have done really good work.

Escort in Bangalore|| Bangalore Female Escorts || Bangalore Escort || Escorts Service in Bangalore || Independent Escorts in Bangalore ||



__________________
Senior Member
Status: Offline
Posts: 140
Date:
Permalink  
 

To click on an element using Selenium with Python 3, you can use the click() method provided by the Selenium WebDriver. Here's an example of how you can do it:
from selenium import webdriver

# Create a new instance of the Firefox driver
driver = webdriver.Firefox()

# Open a webpage
driver.get("https://example.com")

# Find the element you want to click using its ID, class name, XPath, etc.
element = driver.find_element_by_id("element-id")

# Click on the element
element.click()

# Close the browser
driver.quit()

In the example above, we first import the web driver module from Selenium and create a new instance of the Firefox driver. Then, we navigate to a webpage by using the get() method.

Next, we locate the element we want to click using one of the available methods like find_element_by_id(), find_element_by_class_name(), or find_element_by_xpath(). In this case, we used find_element_by_id() and passed the ID of the element as an argument.

Finally, we call the click() method on the element to perform the click action. After that, we can close the browser using driver.quit().

Make sure you have the Selenium package installed (pip install selenium) and the appropriate web driver executable (such as geckodriver for Firefox) available in your system's PATH or provide the executable path explicitly when creating the driver instance.







__________________
Page 1 of 1  sorted by
Quick Reply

Please log in to post quick replies.



Create your own FREE Forum
Report Abuse
Powered by ActiveBoard