1

i have a UI as follows and im trying to automate this.

enter image description here

my html content is as follows:

<div class="medium-5 columns tableheading-td">
  <ul id="ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers" class="assessment-main-layout tabled-list" onchange="ChangeTextColorForSelectedRadio(this);">
    <li>
      <input id="ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_0" type="radio" name="ctl00$ctl00$ContentPlaceHolder1$QuetionListPlaceHolder$BigFiftyPersonalityQuestion1$BigFiftyPersonalityQuestionItem1221754$rdbListAnswers"
        value="0">
      <label for="ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_0"> </label>
    </li>
    <li>
      <input id="ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_1" type="radio" name="ctl00$ctl00$ContentPlaceHolder1$QuetionListPlaceHolder$BigFiftyPersonalityQuestion1$BigFiftyPersonalityQuestionItem1221754$rdbListAnswers"
        value="1">
      <label for="ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_1"> </label>
    </li>
    <li>
      <input id="ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_2" type="radio" name="ctl00$ctl00$ContentPlaceHolder1$QuetionListPlaceHolder$BigFiftyPersonalityQuestion1$BigFiftyPersonalityQuestionItem1221754$rdbListAnswers"
        value="2" style="">
      <label for="ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_2"> </label>
    </li>
    <li>
      <input id="ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_3" type="radio" name="ctl00$ctl00$ContentPlaceHolder1$QuetionListPlaceHolder$BigFiftyPersonalityQuestion1$BigFiftyPersonalityQuestionItem1221754$rdbListAnswers"
        value="3">
      <label for="ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_3"> </label>
    </li>
    <li>
      <input id="ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_4" type="radio" name="ctl00$ctl00$ContentPlaceHolder1$QuetionListPlaceHolder$BigFiftyPersonalityQuestion1$BigFiftyPersonalityQuestionItem1221754$rdbListAnswers"
        value="4">
      <label for="ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_4"> </label>
    </li>
  </ul>
</div>

im trying to click my radio buttons as follows:

IWebElement webElement= CommonProperties.driver.FindElement(By.Id("ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_2"));
webElement.ClickElement();

but it says element is display false. What is he reason for this and how can i fix this? enter image description here

i have tried with xpath:

 IWebElement webElement= CommonProperties.driver.FindElement(By.XPath("//*[@id='ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_0']"));

(having two xpath for radio button and label. even though getting same issue.

//*[@id="ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_0"]

//*[@id="ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers"]/li[1]/label

OpenQA.Selenium.ElementNotVisibleException HResult=0x80131500
Message=element not visible (Session info: chrome=72.0.3626.109)
(Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 10.0.10586 x86_64) Source=WebDriver

StackTrace: at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Remote.RemoteWebElement.Execute(String commandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Remote.RemoteWebElement.Click() at SeleniumBL.SeleniumSetMethods.ClickElement(IWebElement element) in D:\SourceControl\Test\Test \SeleniumHR\SeleniumHR\SeleniumBL\SeleniumSetMethods.cs:line 53 at SeleniumHR.Models.Assesment.BigFiftyAssesment.AssesmentPlay() in D:\SourceControl\Test\Test \SeleniumHR\SeleniumHR\SeleniumHR\Models\Assesment\BigFiftyAssesment.cs:line 47 at SeleniumHR.Models.AssesmentBase.AssesmentStart() in D:\SourceControl\Test\Test \SeleniumHR\SeleniumHR\SeleniumHR\Models\Assesment\AssesmentBase.cs:line 216 at SeleniumHR.Models.Assesment.BigFiftyAssesment.ExecuteAssesment() in D:\SourceControl\Test\Test \SeleniumHR\SeleniumHR\SeleniumHRM\Models\Assesment\BigFiftyAssesment.cs:line 24 at SeleniumHR.Models.Assesment.AssesmentFactory.AssesmentPlay(String AssesmentType) in D:\SourceControl\Test\Test \SeleniumHRM\SeleniumHR\SeleniumHR\Models\Assesment\AssesmentFactory.cs:line 48 at SeleniumHRM.Program.Main(String[] args) in D:\SourceControl\Test\Test \SeleniumHR\SeleniumHR\SeleniumHR\Program.cs:line 49

Nuget i have used as follows: enter image description here

DevT
  • 4,377
  • 13
  • 56
  • 86
  • Sorry Unable to reproduce your problem. It is working here. – KunduK Feb 22 '19 at 13:36
  • Can you post your error trace? – KunduK Feb 22 '19 at 13:36
  • what you could do give wait for the element or check if it is inside any `frame`? – KunduK Feb 22 '19 at 13:38
  • @KajalKundu i have put thread.wait but still same issue – DevT Feb 22 '19 at 13:43
  • Just check if it is inside any iframe? – KunduK Feb 22 '19 at 13:45
  • @KajalKundu - no iframe. i have edited for exception details – DevT Feb 22 '19 at 13:47
  • Sometimes with sites there are two (or more) versions, e.g. desktop and mobile. Are you sure that the first element found is actually visible? Go into Chrome, open the dev tools, and type `$$("#ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_2")`. Does it return 1 or more than 1? That's a CSS selector for an ID (`#`). – JeffC Feb 22 '19 at 14:17
  • @JeffC only one – DevT Feb 22 '19 at 14:21

3 Answers3

1
exception details : element not visible (Session info: chrome=72.0.3626.109) (Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 10.0.10586 x86_64)

This shows that you are using older version of chromedriver=2.37.544315 which is not compatible with chrome version 72. You need to upgrade your chrome driver to become compatible.I believe this will resolve your problem.

Please see the following link.

KunduK
  • 26,790
  • 2
  • 10
  • 32
1

Can you try to use visibilityOfElementLocated this to wait element before click

WebDriverWait wait = new WebDriverWait(driver, 10);
var clickableElement = wait.Until(ExpectedConditions.visibilityOfElementLocated(By.XPath("//*[@id='ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_0']")));
Mr.Kim
  • 154
  • 9
0

I was able to find out my problem. According to style classes radio button is disabled. therefore its always display false. I was able to click on radio button using click on the related label text. I did it as follows

 // get lable for selected radio button
IWebElement radioButtonSelectedLabel = CommonProperties.driver.FindElement(By.CssSelector("label[for='ContentPlaceHolder1_QuetionListPlaceHolder_BigFiftyPersonalityQuestion1_BigFiftyPersonalityQuestionItem1221754_rdbListAnswers_0']"));
// click on the label
radioButtonSelectedLabel.ClickElement();
DevT
  • 4,377
  • 13
  • 56
  • 86