0

Probably many of you have faced the classic error System.NullReferenceException and managed to sort that out.

I have a popup that is displayed with a text box and a button that I need to click, I can see both elements printed out by debugging using

Debug.Print((webDriver.PageSource));

However my selenium code is not able to find them to send Keys or click.

Using IEDriver 3.12 browser: IE v11

The element I need to find is the id "uxEffectiveDateToApply"

ANYBODY HAS AN IDEA HOW TO FIND IT AND SEND KEYS???

<BODY class=popupBGColor style="CURSOR: auto">
<FORM name=form1 id=form1 onsubmit="if (typeof(CommonUtils.okToSubmit) == 'function' &amp;&amp; !CommonUtils.okToSubmit()) { return false; }" action=/PWFE/(S(0eycnhf2h5iz3o1ssojspyno)F(0j_gLwVPxiu2GKnplULS3mGfjTFtlwmzB_si8-zlKxWyEELwfFjmsI22iV1CHszlEIBJMQC_2-ZVisvN9SXno67Tq9XCHr5sVaCLAUSOcb1qoBT781fyZUpg3tqiN4YFSK7vNYLlGsVRfKQc8UeQLTwTCgdVj0ZDZ9uJ_4_BBCWXaLtOv2NYnGm66vvhXP7v0))/Common/Popups/ModifyPolicyPopup.aspx method=post>
<DIV><INPUT name=__LASTFOCUS id=__LASTFOCUS type=hidden> <INPUT name=__EVENTTARGET id=__EVENTTARGET type=hidden> <INPUT name=__EVENTARGUMENT id=__EVENTARGUMENT type=hidden> <INPUT name=__VIEWSTATE id=__VIEWSTATE type=hidden value=/wEPDwULLTE5NjA0NzAyNzIPFgIeE0RlZmF1bHRGb2N1c0ZpZWxkSUQFFnV4RWZmZWN0aXZlRGF0ZVRvQXBwbHkWAgIDDxYCHghvbnN1Ym1pdAVgaWYgKHR5cGVvZihDb21tb25VdGlscy5va1RvU3VibWl0KSA9PSAnZnVuY3Rpb24nICYmICFDb21tb25VdGlscy5va1RvU3VibWl0KCkpIHsgcmV0dXJuIGZhbHNlOyB9FgwCAQ8PFgQeCENzc0NsYXNzBRJsZWZ0TGFiZWwgcmVxdWlyZWQeBF8hU0ICAhYCHgVzdHlsZWVkAgIPDxYEHwIFHGZvcm1GaWVsZCBhY3RpdmVGRiBkYXRlRmllbGQfAwICFgIeCm9ua2V5cHJlc3MFGXJldHVybiBoYW5kbGVEYXRlRW50cnkoKTtkAgUPDxYEHwIFCWxlZnRMYWJlbB8DAgIWAh8EZWQCBg8PFgYfAwICHgdUb29sVGlwBSFQbGVhc2UgYXNrIGRlY2xhcmF0aW9uIHF1ZXN0aW9ucy4fAgUUZm9ybUZpZWxkIHJlYWRPbmx5RkYWBB4JbWF4TGVuZ3RoBQM1MTIeCHJlYWRvbmx5BQhyZWFkb25seWQCBw8PFgQfAgUHcG9wdXBCIB8DAgJkZAIIDw8WBB8CBQdwb3B1cEIgHwMCAmRkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYCBQR1eE9LBQh1eENhbmNlbPa3Azo43mvDbNSqJ//QPkBCWrsiekymA+ADI6AMS2Ff> </DIV>
<SCRIPT type=text/javascript>
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</SCRIPT>

<SCRIPT src="/pwfe/WebResource.axd?d=Bd9HnY22E0AngVNc_WpP2HofdMRdUIbYRH4PyGbmaZ02mrEJBQbbaiMoZ9CN1BlX2FnnE7ORp8C1p5TLTqWaICx_82Hr710-o9WspPSmIxE1&amp;t=636487276482159859" type=text/javascript></SCRIPT>

<SCRIPT src="../../Script/DateUtils.js" type=text/javascript></SCRIPT>

<SCRIPT src="/pwfe/WebResource.axd?d=3OOMIktSZmr42d4H_g71-YYUVqLuhGvfeI7-vnPHa1oobS4oisW8Xrf9o7AXdkEYssN3yllMbBzgGClld2GzJzRf5maXIFVi2MEwG9DJm9U1&amp;t=636487276482159859" type=text/javascript></SCRIPT>

<DIV><INPUT name=__VIEWSTATEGENERATOR id=__VIEWSTATEGENERATOR type=hidden value=EF63028D> <INPUT name=__EVENTVALIDATION id=__EVENTVALIDATION type=hidden value=/wEdAAX/Cp7MfETO5PWQoX/zCFhGQ6AJM4y4w9G4+Jop2F5OMy7E4OakbmY87rUkOq+JRtZUaET0AyxTNex/tloyY62U9KpXvm8AZxamhgcRCC95J11o5hP68DXKrwBdJZpqQJWeJZBZgOvwRavtrpLKW1MI> </DIV>
<DIV id=popupContainer>
<DIV id=titleBarSmall>
<P class=title>Modify Policy</P></DIV>
<DIV class=popupMsgContainer></DIV>
<DIV class=smallCentre><BR></DIV>
<DIV class=centre>
<TABLE class=popupColor id=cancelPolicy border=0 cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
<TD class=firstCol><LABEL class="leftLabel required" id=lblEffectiveDateToApply for=uxEffectiveDateToApply>Effective Date</LABEL></TD>
<TD class=secondCol><INPUT name=uxEffectiveDateToApply class="formField activeFF dateField" id=uxEffectiveDateToApply style="WIDTH: 110px" onkeypress="return handleDateEntry();" type=text maxLength=10> </TD></TR>
<TR>
<TD class=firstCol><LABEL class=leftLabel id=lblPolicyValidationMessage for=uxPolicyValidationMessage>Messages</LABEL></TD>
<TD class=secondCol><TEXTAREA name=uxPolicyValidationMessage tabIndex=-1 title="Please ask declaration questions." class="formField readOnlyFF" id=uxPolicyValidationMessage style="HEIGHT: 300px; WIDTH: 350px" rows=2 cols=20 readOnly maxLength="512">Please ask declaration questions.</TEXTAREA></TD></TR></TBODY></TABLE></DIV>
<DIV id=smallPopupButtonPos><INPUT name=uxOK class="popupB " id=uxOK style="BORDER-LEFT-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-TOP-WIDTH: 0px" onclick='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("uxOK", "", true, "", "", false, false))' type=image alt="OK. " src="../../Images/BlueTheme/ok.gif"> <INPUT name=uxCancel class="popupB " id=uxCancel style="BORDER-LEFT-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-TOP-WIDTH: 0px" onclick='allowModify( false );WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("uxCancel", "", true, "", "", false, false))' type=image alt="Cancel. " src="../../Images/BlueTheme/cancel.gif"> </DIV></DIV>
<SCRIPT type=text/javascript>
Esteban Balvin
  • 117
  • 3
  • 13
  • could you add your code snippet here? – Prany Jun 11 '18 at 04:24
  • Hi Prany, it is too long and does not let me paste it here, but snipped with the HTML code is shown on the original question – Esteban Balvin Jun 11 '18 at 04:44
  • Have you captured window handles and switch to the popup ? – Prany Jun 11 '18 at 05:25
  • @EstebanBalvinRuiz What is your exact question? `find a web element present on the pagesource`, or `to send Keys` or `click`? – undetected Selenium Jun 11 '18 at 06:46
  • Hi, before passing any text to the text box in the popup, first you have to switch to popup box and then send text, the same way you have to do for a button click. Just for referance.[popup](https://stackoverflow.com/questions/19403949/how-to-handle-pop-up-in-selenium-webdriver-using-java) *driver.switchTo().alert().sendKeys("Text");* and *driver.switchTo().alert().accept();* – Priya P Jun 12 '18 at 06:28

0 Answers0