Selenium - how to click on white space area of the text box












-2















I'm trying to click the whitespace area of the text box rather than the text of the element. Is it possible in selenium or is there any other tricky approach?



enter image description here



The red arrow is placed where I want to click



HTML:



<td class="ms-srm-Field-Data-Print" data-height="24" id="stan_servicecategoryid_d">
<div id="stan_servicecategoryid" data-attributename="stan_servicecategoryid" data-formid="bfef905d-acd0-4ee9-a900-2034792789c1" data-fdeid="PrimaryEntity" data-layout="0" tabindex="1070" isinline="true" lookupstyle="single" lookupdialogmultipleselect="0" isinlinenewenabled="1" showasbreadcrumbcontrol="0" showglobalquickcreate="0" openfullform="1" addlookupimagebutton="" role="application" entitylogicalname="stan_servicecategory" entitydisplayname="Service Category" entitytypecode="10041" allowfilteroff="0" disablequickfind="0" disableviewpicker="1" disablemru="1" isdeduplookup="0" availableviewids="{EA878523-32E1-49BB-B0C5-FF97230B5AF2}" resolveemailaddress="0" allowunresolvedpartiesonemailsend="0" defaultviewid="{152B96D2-3BF4-469E-8BB4-52C639E51E50}" class="ms-srm-Inline-Chrome lookup nvarchar" aria-label="Service Category Unique identifier for Service Category associated with Service Request. test Select the Enter key to edit the lookup field, and the Control and Enter keys to open the link">
<div class="ms-srm-Inline-Value ms-srm-Inline-Lookup" style="display: block;">
<label data-for-id="stan_servicecategoryid_label" id="Service Category_label">
<div class="ms-srm-div-NotVisible">Service Category</div>
</label>
<span>
<span contenteditable="false" class="ms-srm-Lookup-Item" id="stan_servicecategoryid_lookupValue" title="test" tabindex="0">test</span>
<div class="ms-srm-Inline-EditIcon keyboardFocusClass" id="stan_servicecategoryid_lookupSearchIconDiv" style="display: none;">
<img src="/_imgs/imagestrips/transparent_spacer.gif" id="stan_servicecategoryid_lookupSearchIcon" class="ms-srm-ImageStrip-search_normal ms-srm-InlineLookupEdit ms-srm-EditLookup-Image" alt="">
</div>
</span>
</div>
<div class="ms-srm-Inline-Edit ms-srm-Inline-Lookup" style="display: none;" lookuptypes="10041">
<table id="stan_servicecategoryid_lookupTable" cellpadding="0" cellspacing="0" lookupid="stan_servicecategoryid" class="ms-srm-Lookup" aria-labelledby="stan_servicecategoryid_c stan_servicecategoryid_w" controlmode="normal" style="width: 100%;table-layout: fixed;">
<tbody>
<tr>
<td valign="top">
<div id="stan_servicecategoryid_lookupDiv" ime-mode="auto" class="ms-srm-Lookup ms-srm-InlineLookupEdit" tabindex="0" aria-labelledby="stan_servicecategoryid_lookupedit" title="Service Category Unique identifier for Service Category associated with Service Request. test" style="display: block; background-color: rgb(171, 192, 231); width: 100%;">
<ul class="ms-srm-InlineLookupEdit">
<li style="display: inline; white-space: nowrap;">
<span class="ms-srm-Lookup-Item" contenteditable="false" isinlinelookup="true">
<span class="ms-srm-LookupItem-Name" id="stan_servicecategoryid_lookupEditSpan" title="test" otype="10041">test</span>
</span>
</li>
</ul>
</div>
<label id="stan_servicecategoryid_lookupedit" class="ms-srm-Hidden-NoBehavior" for="stan_servicecategoryid_ledit">Enter a search term, then select the Enter key to search</label>
<input class="ms-srm-InlineInput ms-srm-InlineLookupEdit" ime-mode="auto" aria-labelledby="stan_servicecategoryid_lookupedit stan_servicecategoryid_w" type="text" id="stan_servicecategoryid_ledit" maxlength="1000" style="display: none;">
</td>
<td class="ms-srm-InlineLookupEdit-Box"></td>
<td class="Lookup_RenderButton_td" id="stan_servicecategoryid_lookupSearch" style="vertical-align:top;width:22px;">
<img src="/_imgs/search_normal.gif" id="stan_servicecategoryid_i" alt="Select a value." class="ms-srm-InlineLookupEdit" title="Select a value.">
<a href="#" id="stan_servicecategoryid_a" tabindex="-1" title="Select a value."></a>
</td>
</tr>
</tbody>
</table>
</div>
<span class="ms-srm-Inline-LockIcon" id="stan_servicecategoryid_lock" style="display: none;">
<img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-srm-ImageStrip-inlineedit_locked" alt="Locked control">
</span>
<span class="ms-srm-Inline-fieldChangeIndicatorIcon" id="stan_servicecategoryid_fieldChangeIndicatorImage" style="visibility: hidden;">
<img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-srm-ImageStrip-field_change_indicator" alt="">
</span>
<span id="stan_servicecategoryid_warnSpan" class="ms-srm-Inline-WarningIcon" title="" style="display: none;" role="alert" aria-live="assertive" aria-atomic="true">
<img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-srm-ImageStrip-inlineedit_warning" alt="Error" id="stan_servicecategoryid_warn">
<div id="stan_servicecategoryid_w" class="ms-srm-Hidden-NoBehavior"></div>
</span>
</div>
<div style="display:none;"></div>
</td>


Selenium:



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

new Actions(driver).MoveToElement(driver.FindElement(by)).SendKeys(Keys.Clear).Perform(); // This will clear the value of the text box









share|improve this question




















  • 6





    Share your code, HTML code sample, desired and current behavior. For now it's too broad

    – Andersson
    Nov 27 '18 at 11:46






  • 1





    Can you do it not in automation?!

    – Moshe Slavin
    Nov 27 '18 at 11:49











  • @Andersson - have added the picture hope it gives you some idea

    – stan
    Nov 27 '18 at 12:00






  • 2





    Not really. This looks like a text input field that you want to click. Still not clear what is exact issue, what is your code, what do you mean by "hyperlink"... Share HTML (not image), your code, exception or misbehavior description

    – Andersson
    Nov 27 '18 at 12:02








  • 1





    If you can click the middle manually and it do what you want then you can do it with Selenium. My guess is that you are locating the wrong element and clicking on it, e.g. the "test" hyperlink instead of the whitespace area. If you post the relevant HTML to the entire area and post your current code attempts and the results (errors, etc.) we can help.

    – JeffC
    Nov 27 '18 at 19:30
















-2















I'm trying to click the whitespace area of the text box rather than the text of the element. Is it possible in selenium or is there any other tricky approach?



enter image description here



The red arrow is placed where I want to click



HTML:



<td class="ms-srm-Field-Data-Print" data-height="24" id="stan_servicecategoryid_d">
<div id="stan_servicecategoryid" data-attributename="stan_servicecategoryid" data-formid="bfef905d-acd0-4ee9-a900-2034792789c1" data-fdeid="PrimaryEntity" data-layout="0" tabindex="1070" isinline="true" lookupstyle="single" lookupdialogmultipleselect="0" isinlinenewenabled="1" showasbreadcrumbcontrol="0" showglobalquickcreate="0" openfullform="1" addlookupimagebutton="" role="application" entitylogicalname="stan_servicecategory" entitydisplayname="Service Category" entitytypecode="10041" allowfilteroff="0" disablequickfind="0" disableviewpicker="1" disablemru="1" isdeduplookup="0" availableviewids="{EA878523-32E1-49BB-B0C5-FF97230B5AF2}" resolveemailaddress="0" allowunresolvedpartiesonemailsend="0" defaultviewid="{152B96D2-3BF4-469E-8BB4-52C639E51E50}" class="ms-srm-Inline-Chrome lookup nvarchar" aria-label="Service Category Unique identifier for Service Category associated with Service Request. test Select the Enter key to edit the lookup field, and the Control and Enter keys to open the link">
<div class="ms-srm-Inline-Value ms-srm-Inline-Lookup" style="display: block;">
<label data-for-id="stan_servicecategoryid_label" id="Service Category_label">
<div class="ms-srm-div-NotVisible">Service Category</div>
</label>
<span>
<span contenteditable="false" class="ms-srm-Lookup-Item" id="stan_servicecategoryid_lookupValue" title="test" tabindex="0">test</span>
<div class="ms-srm-Inline-EditIcon keyboardFocusClass" id="stan_servicecategoryid_lookupSearchIconDiv" style="display: none;">
<img src="/_imgs/imagestrips/transparent_spacer.gif" id="stan_servicecategoryid_lookupSearchIcon" class="ms-srm-ImageStrip-search_normal ms-srm-InlineLookupEdit ms-srm-EditLookup-Image" alt="">
</div>
</span>
</div>
<div class="ms-srm-Inline-Edit ms-srm-Inline-Lookup" style="display: none;" lookuptypes="10041">
<table id="stan_servicecategoryid_lookupTable" cellpadding="0" cellspacing="0" lookupid="stan_servicecategoryid" class="ms-srm-Lookup" aria-labelledby="stan_servicecategoryid_c stan_servicecategoryid_w" controlmode="normal" style="width: 100%;table-layout: fixed;">
<tbody>
<tr>
<td valign="top">
<div id="stan_servicecategoryid_lookupDiv" ime-mode="auto" class="ms-srm-Lookup ms-srm-InlineLookupEdit" tabindex="0" aria-labelledby="stan_servicecategoryid_lookupedit" title="Service Category Unique identifier for Service Category associated with Service Request. test" style="display: block; background-color: rgb(171, 192, 231); width: 100%;">
<ul class="ms-srm-InlineLookupEdit">
<li style="display: inline; white-space: nowrap;">
<span class="ms-srm-Lookup-Item" contenteditable="false" isinlinelookup="true">
<span class="ms-srm-LookupItem-Name" id="stan_servicecategoryid_lookupEditSpan" title="test" otype="10041">test</span>
</span>
</li>
</ul>
</div>
<label id="stan_servicecategoryid_lookupedit" class="ms-srm-Hidden-NoBehavior" for="stan_servicecategoryid_ledit">Enter a search term, then select the Enter key to search</label>
<input class="ms-srm-InlineInput ms-srm-InlineLookupEdit" ime-mode="auto" aria-labelledby="stan_servicecategoryid_lookupedit stan_servicecategoryid_w" type="text" id="stan_servicecategoryid_ledit" maxlength="1000" style="display: none;">
</td>
<td class="ms-srm-InlineLookupEdit-Box"></td>
<td class="Lookup_RenderButton_td" id="stan_servicecategoryid_lookupSearch" style="vertical-align:top;width:22px;">
<img src="/_imgs/search_normal.gif" id="stan_servicecategoryid_i" alt="Select a value." class="ms-srm-InlineLookupEdit" title="Select a value.">
<a href="#" id="stan_servicecategoryid_a" tabindex="-1" title="Select a value."></a>
</td>
</tr>
</tbody>
</table>
</div>
<span class="ms-srm-Inline-LockIcon" id="stan_servicecategoryid_lock" style="display: none;">
<img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-srm-ImageStrip-inlineedit_locked" alt="Locked control">
</span>
<span class="ms-srm-Inline-fieldChangeIndicatorIcon" id="stan_servicecategoryid_fieldChangeIndicatorImage" style="visibility: hidden;">
<img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-srm-ImageStrip-field_change_indicator" alt="">
</span>
<span id="stan_servicecategoryid_warnSpan" class="ms-srm-Inline-WarningIcon" title="" style="display: none;" role="alert" aria-live="assertive" aria-atomic="true">
<img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-srm-ImageStrip-inlineedit_warning" alt="Error" id="stan_servicecategoryid_warn">
<div id="stan_servicecategoryid_w" class="ms-srm-Hidden-NoBehavior"></div>
</span>
</div>
<div style="display:none;"></div>
</td>


Selenium:



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

new Actions(driver).MoveToElement(driver.FindElement(by)).SendKeys(Keys.Clear).Perform(); // This will clear the value of the text box









share|improve this question




















  • 6





    Share your code, HTML code sample, desired and current behavior. For now it's too broad

    – Andersson
    Nov 27 '18 at 11:46






  • 1





    Can you do it not in automation?!

    – Moshe Slavin
    Nov 27 '18 at 11:49











  • @Andersson - have added the picture hope it gives you some idea

    – stan
    Nov 27 '18 at 12:00






  • 2





    Not really. This looks like a text input field that you want to click. Still not clear what is exact issue, what is your code, what do you mean by "hyperlink"... Share HTML (not image), your code, exception or misbehavior description

    – Andersson
    Nov 27 '18 at 12:02








  • 1





    If you can click the middle manually and it do what you want then you can do it with Selenium. My guess is that you are locating the wrong element and clicking on it, e.g. the "test" hyperlink instead of the whitespace area. If you post the relevant HTML to the entire area and post your current code attempts and the results (errors, etc.) we can help.

    – JeffC
    Nov 27 '18 at 19:30














-2












-2








-2








I'm trying to click the whitespace area of the text box rather than the text of the element. Is it possible in selenium or is there any other tricky approach?



enter image description here



The red arrow is placed where I want to click



HTML:



<td class="ms-srm-Field-Data-Print" data-height="24" id="stan_servicecategoryid_d">
<div id="stan_servicecategoryid" data-attributename="stan_servicecategoryid" data-formid="bfef905d-acd0-4ee9-a900-2034792789c1" data-fdeid="PrimaryEntity" data-layout="0" tabindex="1070" isinline="true" lookupstyle="single" lookupdialogmultipleselect="0" isinlinenewenabled="1" showasbreadcrumbcontrol="0" showglobalquickcreate="0" openfullform="1" addlookupimagebutton="" role="application" entitylogicalname="stan_servicecategory" entitydisplayname="Service Category" entitytypecode="10041" allowfilteroff="0" disablequickfind="0" disableviewpicker="1" disablemru="1" isdeduplookup="0" availableviewids="{EA878523-32E1-49BB-B0C5-FF97230B5AF2}" resolveemailaddress="0" allowunresolvedpartiesonemailsend="0" defaultviewid="{152B96D2-3BF4-469E-8BB4-52C639E51E50}" class="ms-srm-Inline-Chrome lookup nvarchar" aria-label="Service Category Unique identifier for Service Category associated with Service Request. test Select the Enter key to edit the lookup field, and the Control and Enter keys to open the link">
<div class="ms-srm-Inline-Value ms-srm-Inline-Lookup" style="display: block;">
<label data-for-id="stan_servicecategoryid_label" id="Service Category_label">
<div class="ms-srm-div-NotVisible">Service Category</div>
</label>
<span>
<span contenteditable="false" class="ms-srm-Lookup-Item" id="stan_servicecategoryid_lookupValue" title="test" tabindex="0">test</span>
<div class="ms-srm-Inline-EditIcon keyboardFocusClass" id="stan_servicecategoryid_lookupSearchIconDiv" style="display: none;">
<img src="/_imgs/imagestrips/transparent_spacer.gif" id="stan_servicecategoryid_lookupSearchIcon" class="ms-srm-ImageStrip-search_normal ms-srm-InlineLookupEdit ms-srm-EditLookup-Image" alt="">
</div>
</span>
</div>
<div class="ms-srm-Inline-Edit ms-srm-Inline-Lookup" style="display: none;" lookuptypes="10041">
<table id="stan_servicecategoryid_lookupTable" cellpadding="0" cellspacing="0" lookupid="stan_servicecategoryid" class="ms-srm-Lookup" aria-labelledby="stan_servicecategoryid_c stan_servicecategoryid_w" controlmode="normal" style="width: 100%;table-layout: fixed;">
<tbody>
<tr>
<td valign="top">
<div id="stan_servicecategoryid_lookupDiv" ime-mode="auto" class="ms-srm-Lookup ms-srm-InlineLookupEdit" tabindex="0" aria-labelledby="stan_servicecategoryid_lookupedit" title="Service Category Unique identifier for Service Category associated with Service Request. test" style="display: block; background-color: rgb(171, 192, 231); width: 100%;">
<ul class="ms-srm-InlineLookupEdit">
<li style="display: inline; white-space: nowrap;">
<span class="ms-srm-Lookup-Item" contenteditable="false" isinlinelookup="true">
<span class="ms-srm-LookupItem-Name" id="stan_servicecategoryid_lookupEditSpan" title="test" otype="10041">test</span>
</span>
</li>
</ul>
</div>
<label id="stan_servicecategoryid_lookupedit" class="ms-srm-Hidden-NoBehavior" for="stan_servicecategoryid_ledit">Enter a search term, then select the Enter key to search</label>
<input class="ms-srm-InlineInput ms-srm-InlineLookupEdit" ime-mode="auto" aria-labelledby="stan_servicecategoryid_lookupedit stan_servicecategoryid_w" type="text" id="stan_servicecategoryid_ledit" maxlength="1000" style="display: none;">
</td>
<td class="ms-srm-InlineLookupEdit-Box"></td>
<td class="Lookup_RenderButton_td" id="stan_servicecategoryid_lookupSearch" style="vertical-align:top;width:22px;">
<img src="/_imgs/search_normal.gif" id="stan_servicecategoryid_i" alt="Select a value." class="ms-srm-InlineLookupEdit" title="Select a value.">
<a href="#" id="stan_servicecategoryid_a" tabindex="-1" title="Select a value."></a>
</td>
</tr>
</tbody>
</table>
</div>
<span class="ms-srm-Inline-LockIcon" id="stan_servicecategoryid_lock" style="display: none;">
<img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-srm-ImageStrip-inlineedit_locked" alt="Locked control">
</span>
<span class="ms-srm-Inline-fieldChangeIndicatorIcon" id="stan_servicecategoryid_fieldChangeIndicatorImage" style="visibility: hidden;">
<img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-srm-ImageStrip-field_change_indicator" alt="">
</span>
<span id="stan_servicecategoryid_warnSpan" class="ms-srm-Inline-WarningIcon" title="" style="display: none;" role="alert" aria-live="assertive" aria-atomic="true">
<img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-srm-ImageStrip-inlineedit_warning" alt="Error" id="stan_servicecategoryid_warn">
<div id="stan_servicecategoryid_w" class="ms-srm-Hidden-NoBehavior"></div>
</span>
</div>
<div style="display:none;"></div>
</td>


Selenium:



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

new Actions(driver).MoveToElement(driver.FindElement(by)).SendKeys(Keys.Clear).Perform(); // This will clear the value of the text box









share|improve this question
















I'm trying to click the whitespace area of the text box rather than the text of the element. Is it possible in selenium or is there any other tricky approach?



enter image description here



The red arrow is placed where I want to click



HTML:



<td class="ms-srm-Field-Data-Print" data-height="24" id="stan_servicecategoryid_d">
<div id="stan_servicecategoryid" data-attributename="stan_servicecategoryid" data-formid="bfef905d-acd0-4ee9-a900-2034792789c1" data-fdeid="PrimaryEntity" data-layout="0" tabindex="1070" isinline="true" lookupstyle="single" lookupdialogmultipleselect="0" isinlinenewenabled="1" showasbreadcrumbcontrol="0" showglobalquickcreate="0" openfullform="1" addlookupimagebutton="" role="application" entitylogicalname="stan_servicecategory" entitydisplayname="Service Category" entitytypecode="10041" allowfilteroff="0" disablequickfind="0" disableviewpicker="1" disablemru="1" isdeduplookup="0" availableviewids="{EA878523-32E1-49BB-B0C5-FF97230B5AF2}" resolveemailaddress="0" allowunresolvedpartiesonemailsend="0" defaultviewid="{152B96D2-3BF4-469E-8BB4-52C639E51E50}" class="ms-srm-Inline-Chrome lookup nvarchar" aria-label="Service Category Unique identifier for Service Category associated with Service Request. test Select the Enter key to edit the lookup field, and the Control and Enter keys to open the link">
<div class="ms-srm-Inline-Value ms-srm-Inline-Lookup" style="display: block;">
<label data-for-id="stan_servicecategoryid_label" id="Service Category_label">
<div class="ms-srm-div-NotVisible">Service Category</div>
</label>
<span>
<span contenteditable="false" class="ms-srm-Lookup-Item" id="stan_servicecategoryid_lookupValue" title="test" tabindex="0">test</span>
<div class="ms-srm-Inline-EditIcon keyboardFocusClass" id="stan_servicecategoryid_lookupSearchIconDiv" style="display: none;">
<img src="/_imgs/imagestrips/transparent_spacer.gif" id="stan_servicecategoryid_lookupSearchIcon" class="ms-srm-ImageStrip-search_normal ms-srm-InlineLookupEdit ms-srm-EditLookup-Image" alt="">
</div>
</span>
</div>
<div class="ms-srm-Inline-Edit ms-srm-Inline-Lookup" style="display: none;" lookuptypes="10041">
<table id="stan_servicecategoryid_lookupTable" cellpadding="0" cellspacing="0" lookupid="stan_servicecategoryid" class="ms-srm-Lookup" aria-labelledby="stan_servicecategoryid_c stan_servicecategoryid_w" controlmode="normal" style="width: 100%;table-layout: fixed;">
<tbody>
<tr>
<td valign="top">
<div id="stan_servicecategoryid_lookupDiv" ime-mode="auto" class="ms-srm-Lookup ms-srm-InlineLookupEdit" tabindex="0" aria-labelledby="stan_servicecategoryid_lookupedit" title="Service Category Unique identifier for Service Category associated with Service Request. test" style="display: block; background-color: rgb(171, 192, 231); width: 100%;">
<ul class="ms-srm-InlineLookupEdit">
<li style="display: inline; white-space: nowrap;">
<span class="ms-srm-Lookup-Item" contenteditable="false" isinlinelookup="true">
<span class="ms-srm-LookupItem-Name" id="stan_servicecategoryid_lookupEditSpan" title="test" otype="10041">test</span>
</span>
</li>
</ul>
</div>
<label id="stan_servicecategoryid_lookupedit" class="ms-srm-Hidden-NoBehavior" for="stan_servicecategoryid_ledit">Enter a search term, then select the Enter key to search</label>
<input class="ms-srm-InlineInput ms-srm-InlineLookupEdit" ime-mode="auto" aria-labelledby="stan_servicecategoryid_lookupedit stan_servicecategoryid_w" type="text" id="stan_servicecategoryid_ledit" maxlength="1000" style="display: none;">
</td>
<td class="ms-srm-InlineLookupEdit-Box"></td>
<td class="Lookup_RenderButton_td" id="stan_servicecategoryid_lookupSearch" style="vertical-align:top;width:22px;">
<img src="/_imgs/search_normal.gif" id="stan_servicecategoryid_i" alt="Select a value." class="ms-srm-InlineLookupEdit" title="Select a value.">
<a href="#" id="stan_servicecategoryid_a" tabindex="-1" title="Select a value."></a>
</td>
</tr>
</tbody>
</table>
</div>
<span class="ms-srm-Inline-LockIcon" id="stan_servicecategoryid_lock" style="display: none;">
<img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-srm-ImageStrip-inlineedit_locked" alt="Locked control">
</span>
<span class="ms-srm-Inline-fieldChangeIndicatorIcon" id="stan_servicecategoryid_fieldChangeIndicatorImage" style="visibility: hidden;">
<img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-srm-ImageStrip-field_change_indicator" alt="">
</span>
<span id="stan_servicecategoryid_warnSpan" class="ms-srm-Inline-WarningIcon" title="" style="display: none;" role="alert" aria-live="assertive" aria-atomic="true">
<img src="/_imgs/imagestrips/transparent_spacer.gif" class="ms-srm-ImageStrip-inlineedit_warning" alt="Error" id="stan_servicecategoryid_warn">
<div id="stan_servicecategoryid_w" class="ms-srm-Hidden-NoBehavior"></div>
</span>
</div>
<div style="display:none;"></div>
</td>


Selenium:



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

new Actions(driver).MoveToElement(driver.FindElement(by)).SendKeys(Keys.Clear).Perform(); // This will clear the value of the text box






java selenium selenium-webdriver xpath






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 28 '18 at 16:06









JeffC

12.6k41633




12.6k41633










asked Nov 27 '18 at 11:43









stanstan

327




327








  • 6





    Share your code, HTML code sample, desired and current behavior. For now it's too broad

    – Andersson
    Nov 27 '18 at 11:46






  • 1





    Can you do it not in automation?!

    – Moshe Slavin
    Nov 27 '18 at 11:49











  • @Andersson - have added the picture hope it gives you some idea

    – stan
    Nov 27 '18 at 12:00






  • 2





    Not really. This looks like a text input field that you want to click. Still not clear what is exact issue, what is your code, what do you mean by "hyperlink"... Share HTML (not image), your code, exception or misbehavior description

    – Andersson
    Nov 27 '18 at 12:02








  • 1





    If you can click the middle manually and it do what you want then you can do it with Selenium. My guess is that you are locating the wrong element and clicking on it, e.g. the "test" hyperlink instead of the whitespace area. If you post the relevant HTML to the entire area and post your current code attempts and the results (errors, etc.) we can help.

    – JeffC
    Nov 27 '18 at 19:30














  • 6





    Share your code, HTML code sample, desired and current behavior. For now it's too broad

    – Andersson
    Nov 27 '18 at 11:46






  • 1





    Can you do it not in automation?!

    – Moshe Slavin
    Nov 27 '18 at 11:49











  • @Andersson - have added the picture hope it gives you some idea

    – stan
    Nov 27 '18 at 12:00






  • 2





    Not really. This looks like a text input field that you want to click. Still not clear what is exact issue, what is your code, what do you mean by "hyperlink"... Share HTML (not image), your code, exception or misbehavior description

    – Andersson
    Nov 27 '18 at 12:02








  • 1





    If you can click the middle manually and it do what you want then you can do it with Selenium. My guess is that you are locating the wrong element and clicking on it, e.g. the "test" hyperlink instead of the whitespace area. If you post the relevant HTML to the entire area and post your current code attempts and the results (errors, etc.) we can help.

    – JeffC
    Nov 27 '18 at 19:30








6




6





Share your code, HTML code sample, desired and current behavior. For now it's too broad

– Andersson
Nov 27 '18 at 11:46





Share your code, HTML code sample, desired and current behavior. For now it's too broad

– Andersson
Nov 27 '18 at 11:46




1




1





Can you do it not in automation?!

– Moshe Slavin
Nov 27 '18 at 11:49





Can you do it not in automation?!

– Moshe Slavin
Nov 27 '18 at 11:49













@Andersson - have added the picture hope it gives you some idea

– stan
Nov 27 '18 at 12:00





@Andersson - have added the picture hope it gives you some idea

– stan
Nov 27 '18 at 12:00




2




2





Not really. This looks like a text input field that you want to click. Still not clear what is exact issue, what is your code, what do you mean by "hyperlink"... Share HTML (not image), your code, exception or misbehavior description

– Andersson
Nov 27 '18 at 12:02







Not really. This looks like a text input field that you want to click. Still not clear what is exact issue, what is your code, what do you mean by "hyperlink"... Share HTML (not image), your code, exception or misbehavior description

– Andersson
Nov 27 '18 at 12:02






1




1





If you can click the middle manually and it do what you want then you can do it with Selenium. My guess is that you are locating the wrong element and clicking on it, e.g. the "test" hyperlink instead of the whitespace area. If you post the relevant HTML to the entire area and post your current code attempts and the results (errors, etc.) we can help.

– JeffC
Nov 27 '18 at 19:30





If you can click the middle manually and it do what you want then you can do it with Selenium. My guess is that you are locating the wrong element and clicking on it, e.g. the "test" hyperlink instead of the whitespace area. If you post the relevant HTML to the entire area and post your current code attempts and the results (errors, etc.) we can help.

– JeffC
Nov 27 '18 at 19:30












1 Answer
1






active

oldest

votes


















0














Use ACTIONS (or ActionChains in Python)



If you simulate moveToElement(element) and click(), it clicks exactly in the centre of the element. If the text is long and the above still clicks on the text, use moveToElement (with offset), giving it x-offset as required.



Java:



Actions action = new Actions(driver);
action.moveToElement(element).click().perform();


or



action.moveToElement(element, x-offset, 0).click().perform();


Python:



from selenium.webdriver.common.action_chains import ActionChains as AC

AC(driver).move_to_element(element).click().perform()


or



AC(driver).move_to_element_with_offset(element, x-offset, 0).click().perform()





share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53498918%2fselenium-how-to-click-on-white-space-area-of-the-text-box%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Use ACTIONS (or ActionChains in Python)



    If you simulate moveToElement(element) and click(), it clicks exactly in the centre of the element. If the text is long and the above still clicks on the text, use moveToElement (with offset), giving it x-offset as required.



    Java:



    Actions action = new Actions(driver);
    action.moveToElement(element).click().perform();


    or



    action.moveToElement(element, x-offset, 0).click().perform();


    Python:



    from selenium.webdriver.common.action_chains import ActionChains as AC

    AC(driver).move_to_element(element).click().perform()


    or



    AC(driver).move_to_element_with_offset(element, x-offset, 0).click().perform()





    share|improve this answer






























      0














      Use ACTIONS (or ActionChains in Python)



      If you simulate moveToElement(element) and click(), it clicks exactly in the centre of the element. If the text is long and the above still clicks on the text, use moveToElement (with offset), giving it x-offset as required.



      Java:



      Actions action = new Actions(driver);
      action.moveToElement(element).click().perform();


      or



      action.moveToElement(element, x-offset, 0).click().perform();


      Python:



      from selenium.webdriver.common.action_chains import ActionChains as AC

      AC(driver).move_to_element(element).click().perform()


      or



      AC(driver).move_to_element_with_offset(element, x-offset, 0).click().perform()





      share|improve this answer




























        0












        0








        0







        Use ACTIONS (or ActionChains in Python)



        If you simulate moveToElement(element) and click(), it clicks exactly in the centre of the element. If the text is long and the above still clicks on the text, use moveToElement (with offset), giving it x-offset as required.



        Java:



        Actions action = new Actions(driver);
        action.moveToElement(element).click().perform();


        or



        action.moveToElement(element, x-offset, 0).click().perform();


        Python:



        from selenium.webdriver.common.action_chains import ActionChains as AC

        AC(driver).move_to_element(element).click().perform()


        or



        AC(driver).move_to_element_with_offset(element, x-offset, 0).click().perform()





        share|improve this answer















        Use ACTIONS (or ActionChains in Python)



        If you simulate moveToElement(element) and click(), it clicks exactly in the centre of the element. If the text is long and the above still clicks on the text, use moveToElement (with offset), giving it x-offset as required.



        Java:



        Actions action = new Actions(driver);
        action.moveToElement(element).click().perform();


        or



        action.moveToElement(element, x-offset, 0).click().perform();


        Python:



        from selenium.webdriver.common.action_chains import ActionChains as AC

        AC(driver).move_to_element(element).click().perform()


        or



        AC(driver).move_to_element_with_offset(element, x-offset, 0).click().perform()






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 28 '18 at 11:25

























        answered Nov 28 '18 at 11:19









        AlichinoAlichino

        7961618




        7961618
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53498918%2fselenium-how-to-click-on-white-space-area-of-the-text-box%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)