How can I click on a checkbox in a webpage using selenium mimicking manual approach? How can I click on a checkbox in a webpage using selenium mimicking manual approach? selenium selenium

How can I click on a checkbox in a webpage using selenium mimicking manual approach?


You can use the PyMouse package (python package here) to move to the (x,y) position of the object on the webpage and simulate a mouse click.

from pymouse import PyMousemouse = PyMouse()def click(self, x,y):    """Mouse event click for webdriver"""    global mouse    mouse.click(x,y,1)


CAPTCHA is used to stop website automation & that's why it can not be automated using selenium. Adn for same reason, your not able to select CAPTCHA tick box. Please refer these link for more info: https://sqa.stackexchange.com/questions/17022/how-to-fill-captcha-using-test-automation


Here is the sample code to select the check box that will trigger the recaptcha images.

url = "https://www.google.com/recaptcha/api2/demo"driver.get(url)driver.switch_to.frame(driver.find_element_by_xpath("//iframe[starts-with(@name,'a-')]"))# update the class name based on the UAT implementation (if it's different)driver.find_element_by_class_name("recaptcha-checkbox-border").click()

But still you have to complete either image selection/use voice-to-text api to resolve the captcha.The possible options are using 3rd party APIs or check you have the APIs available in truepeoplesearch where you can get the required information as response.

Edit 1: Using the API and html parser.

url = "https://www.truepeoplesearch.com/results?name=John%20Smithers"payload = {}headers= {}response = requests.request("GET", url, headers=headers, data = payload)html_content = response.text.encode('utf8')# now you can load this content into the lxml.html parser and get the informationhtml_content = response.text.encode('utf8')root=lxml.html.document_fromstring(html_content)content=root.xpath("//div[@class='h4']") # here I am get the namesfor name in content:    print(name.text_content() + '\n')