How can I click on male tag in facebook using selenium?

0 votes
I am unable to click on male radio button on facebook. Apparently both male and female RB has the same class name.

Please someone help me in this. I am stuck here actually.
Dec 20, 2018 in Selenium by Jino
• 5,660 points
241 views

1 answer to this question.

0 votes

There is an approach for locating an element using selenium.

First look for the ID then CSS Selector and then the XPath and then the Class Name.

Here is what I got from facebook both female and male have different ID and that is what you should be looking for.

<input type="radio" name="sex" value="1" id="u_0_9">

<input type="radio" name="sex" value="2" id="u_0_a">

Now that you know as how to approach the problem. I would suggest that you do the remaining thing rather than getting the complete answer.

Here is what I did

driver.findElement(By.xpath("//*[contains(text(),'Female')]")).click();
driver.findElement(By.xpath("//*[contains(text(),'Male')]")).click();

answered Dec 20, 2018 by Nabarupa

Related Questions In Selenium

0 votes
1 answer
+1 vote
2 answers

How can I delete an element in Selenium using Python?

You can directly delete the node using ...READ MORE

answered Sep 14, 2019 in Selenium by tonystark
• 500 points
3,222 views
0 votes
1 answer

How can I scroll a web page in Mozilla Firefox using Selenium?

Hi Rohan, steps to scroll a webpage in ...READ MORE

answered May 13, 2019 in Selenium by Pratibha
• 3,690 points
541 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
2,155 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,870 points
1,793 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,870 points
1,756 views
+1 vote
1 answer
0 votes
1 answer