Unable to click button inside frame using selenium vba
I am beginner to vba selenium. i want to click a button which is inside a frame. i tried with below codes it didn't work. Can anyone help me? Thanks
VBA Code:
ch.SwitchToFrame (1)
ch.FindElementByXPath("//*[@id='ctl00_m_g_4407ef25_fbd3_4301_922c_f996c0f26235_FormControl0_V1_I1_B3']")
HTML Code:
<input style="text-align:center" onclick="return (Button.OnClick(this, event));" onfocus="return (Button.OnFocus(this, event));" id="ctl00_m_g_4407ef25_fbd3_4301_922c_f996c0f26235_FormControl0_V1_I1_B3" scriptclass="Button" class="i_lgkamPX909UfcKnV_3 a4_lgkamPX909UfcKnV_3 a2_lgkamPX909UfcKnV_3" wrapped="true" direction="ltr" viewdatanode="4" formid="ctl00_m_g_4407ef25_fbd3_4301_922c_f996c0f26235_FormControl0" originalid="V1_I1_B3" tabindex="0" title="" buttonid="CTRL2" value="Vendor" type="button">
Hello. Remember that switchtoframe uses a zero-based index. Try "switchtoFrame(0)".
@Juampa2 Thanks for your response. I tried that too. I get run-time error 7 NoSuchElementError Element not found for XPath=//*[
Does it got anything to do with browser version and driver version? Mine is chrome Version 63.0.3239.108
once the driver has started, pause the code just before ch.SwitchToFrame (1) and try to modify the frame id manually : in the developper tool of your browser (if you're using Chrome for example : F12). Find the in which your id='ctl00_m_g_4407ef25_fbd3_4301_922c_f996c0f26235_FormControl0_V1_I1_B3' is and add something like . Then, try : ch.SwitchToFrame("mytest") just to make sure the driver is switching on the correct frame. And then, once you're sure that the correct frame has been switched on, try ch.FindElementById("ctl00_m_g_4407ef25_fbd3_4301_922c_f996c0f26235_FormControl0_V1_I1_B3") instead of XPath.
if it works, then it means probably that you have many frames and switching to frame as you do does not ensure you that you've switched on the correct frame.
As a workaround, I try to open the frame separately, then access its elements.