Hack Forums
[C#] Need Help Selecting Element [Selenium C#] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Need Help Selecting Element [Selenium C#] (/showthread.php?tid=5715126)



Need Help Selecting Element [Selenium C#] - FryPan - Sep 10, 2017

Code
<select class="ui-textfield ui-textfield-system sa-error-field" style="display: inline-block;">

Tried XPath, CSSSelector etc, it always says that it can't find the element. Help would be much appreciated!

Full "outer" code. I'm trying to select the element and use "SelectByValue" to choose the item "London".

PHP Code

<?php 
<div class="sa-form-control sa-form-field sa-select-input sa-province-wrapper" data-widget-cid="widget-14" style="padding-bottom: 20px;">
                <
input name="province" class="ui-textfield ui-textfield-system sa-error-field" style="display: none;" maxlength="64" type="text">
                <
select class="ui-textfield ui-textfield-system sa-error-field" style="display: inline-block;"><option value="">--Please select--</option><option value="Aberdeenshire">Aberdeenshire</option></select>
            <
p class="sa-error-tips" style="display: block;">Please select a State/Province/Region</p></div> 



* - severos - Sep 10, 2017

Are you sure you've written the correct css selector??


* - uint32 - Sep 11, 2017

I think you've got a wrong XPath selector. Try this:
Code
//option[@value='Aberdeenshire']
Decomposition:
//: select all
option: select option nodes
[]: node descriptior
@: attribute
value: atribute named value
='(value)': expected value