1

This is the code im triying to access

<div class="field checkbox">
  <label class="radio">
    <input payoneer="CheckBox" type="checkbox" name="ctl00$plcMainArea$SignDocument_4_2" validate="validate" data-rule-required="true" data-msg-required="This field is required." hidefocus="hidefocus" class="field-data" id="SignDocument_4_2" data-sign-document-type="4_2">&nbsp;I agree to the
    <a href="pagecontent.payoneer?rsckey=ProcessorTypeDebitCard.ElectronicDisclosure&amp;pid=Y0LwV0AQC7cY%2b5AIqsZl1g%3d%3d" target="_blank">Electronic Disclosures</a>
    <a href="pagecontent.payoneer?rsckey=ProcessorTypeDebitCard.Privacy&amp;pid=Y0LwV0AQC7cY%2b5AIqsZl1g%3d%3d" target="_blank">Privacy Policy</a>
  </label>
</div>

Im triying to find the element by ID and click the checkbox that's on it

driver.FindElement(By.Id("SignDocument_4_2")).Click();

This is the Exception i get

System.InvalidOperationException was unhandled
  HResult=-2146233079
  Message=unknown error: Element is not clickable at point (257, 955). Other element would receive the click: <a href="pagecontent.payoneer?rsckey=ProcessorTypeDebitCard.ElectronicDisclosure&amp;pid=Y0LwV0AQC7cY%2b5AIqsZl1g%3d%3d" target="_blank">...</a>
  (Session info: chrome=48.0.2564.116)
  (Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64)
  Source=WebDriver
  StackTrace:
       at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
       at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
       at OpenQA.Selenium.Remote.RemoteWebDriver.InternalExecute(String driverCommandToExecute, Dictionary`2 parameters)
       at OpenQA.Selenium.Remote.RemoteWebElement.Execute(String commandToExecute, Dictionary`2 parameters)
       at OpenQA.Selenium.Remote.RemoteWebElement.Click()
       at Payoneer.Exam.Main(String[] args) in c:\Users\Alberto Chocron\Documents\Visual Studio 2013\Projects\PayoneerTest\Payoneer\Program.cs:line 105
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
Guy
  • 46,488
  • 10
  • 44
  • 88
AutDev
  • 65
  • 8

2 Answers2

1

The error Element is not clickable at point (257, 955). Other element would receive the click means the element you want to click at is not visible for Selenium. To simulate movement to the element use MoveToElement from Actions class

IWebElement checkbox = driver.FindElement(By.Id("SignDocument_4_2"));
Actions actions = new Actions(driver);
actions.MoveToElement(checkbox).perform();
checkbox.Click();

You can also try sending click to checkbox parents

driver.FindElement(By.ClassName("checkbox")).Click();
// or
driver.FindElement(By.ClassName("radio")).Click();

Another option is using java script click

IWebElement checkbox = driver.FindElement(By.Id("SignDocument_4_2"));
IJavascriptExecutor executor = (IJavascriptExecutor)driver;
executor.ExecuteScript("arguments[0].click();", checkbox);
Guy
  • 46,488
  • 10
  • 44
  • 88
  • http://imageshack.com/a/img921/6996/STgJnq.png Unfortunately I get the same error – AutDev Mar 03 '16 at 16:29
  • @AutDev can you see the checkbox in the screen when the code is running? – Guy Mar 03 '16 at 16:33
  • @AutDev I also added two more options you can try. – Guy Mar 03 '16 at 16:38
  • Yes, I can see the checkbox. Im using Chrome. Wierdly enough when i resize the window to half of the screen , Im able to click on the buttons. Meaning , I resize chrome to half screeen and Visual studio the other half. But when maximized , this problem remains – AutDev Mar 03 '16 at 16:39
  • When triying to click to checkbox parents the actual link opens. But it doesnt check the box – AutDev Mar 03 '16 at 16:43
  • @AutDev I added another solution using java script. – Guy Mar 03 '16 at 16:51
  • What reference or package do I have to install to use "IJavascriptExecutor"? – AutDev Mar 03 '16 at 17:02
  • @AutDev it should be in `using OpenQA.Selenium;` or `using OpenQA.Selenium.Support.UI;`, I don't remember exactly. – Guy Mar 03 '16 at 17:06
0

First of all, see that you are using proper try and catch block or the method is getting thrown properly and secondly, actually the point is not getting detected. so try

            string checkboxXPath = "//input[contains(@id, SignDocument_4_2')]"
            IWebElement elementToClick = driver.FindElement(By.XPath(checkboxXPath));
            elementToClick.Click();
Fazz
  • 101
  • 10