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,770 points
489 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

+1 vote
2 answers
+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
6,964 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
950 views
0 votes
2 answers

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,520 points
3,827 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,807 views
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,890 points
2,773 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
3,149 views
+1 vote
1 answer
0 votes
1 answer