我无法点击"登录"按钮。
var footNotesPanel = true;
var referencesPanel = true;
var imagesPanel = true;
var showPanels = {
footNotesPanel: footNotesPanel,
referencesPanel: referencesPanel,
imagesPanel: imagesPanel
}
/*
Option 2 - for showing/hiding side panels
1 ) create all your panels as they would appear, with all the data, but hide them with display:none;
2 ) call show panel function to show a panel.
*/
var showPanel(panel_id) {
var panel_element = $("#" + panel_id); /*panel that you want to show ( is hidden atm but somewhere on the page */
if (!panel_element.length) {
return false; //no panel with this id currently on page
} else {
//check the panel id and do some custom editing if needed, eg.
if (panel_id == "main_side_panel") {
//add some additional classes to body element etc
}
panel_element.show();
//Or Another option that you probably are looking for is below
if (panel_id == "footnotes_panel") {
showFootnotesPanel();
} else if (panel_id == "images_panel") {
showImagesPanel();
}
}
}
// And use it like this:
<div id="footnotes_panel" onclick="showPanel('footnotes_panel')"></div>
// Or simply get the element id from `event.target` and use `showPanel()` without arguments.
我尝试过使用以下方法(xpath,css,id),但它无效。 我无法点击按钮。
以下是我的测试步骤控制..
<div id="im">
<input id="m_CultureCodeIptLogin" value="EN-US" type="hidden">
<input id="m_AffIdIptLogin" value="714" type="hidden">
<div class="ccerr"><p class="txt">The password you entered was invalid. Please try again.</p></div>
<div class="field">
<label class="errTxt">Password:<span class="red">*</span></label><span class="errtt" style="display:block"></span>
<input id="m_Password" name="m_Password" maxlength="50" class="errField" autocomplete="off" type="password">
</div>
<p><a id="forgotPassword" class="hideDim">Forgot Your Password?</a></p>
<p class="newEmail"><a id="editEmail2" class="hideDim" onclick="" href="javascript:ResetUpdateEmail()">New Email Address?</a></p>
<div class="bctr">
<button type="submit" id="btnLogin" name="btnLogin" data-navelement="ipt cart|landing:log in"><span>Log in</span></button>
</div>
</div>
</div>
如果您不理解我问题的任何部分,请告诉我。 谢谢
答案 0 :(得分:0)
<control tofind="#btnLogin" findby="cssselector" />
<control tofind="#bctr" findby="cssselector" />
<control tofind=".bctr" findby="cssselector" />
<control tofind="#btnLogin" findby="xpath" />
<control tofind="btnLogin" findby="id" />
<control tofind="//*[@button='btnLogin']" findby="xpath" />
<control tofind="//*[@id='btnLogin']" findby="xpath" />
<control tofind="//*[@id='btnLogin']" findby="xpath" />
<control tofind="//div[@class='bctr']" findby="xpath" />
<control tofind="//button[@id='btnLogin']" findby="xpath" />
<control tofind="//*[@class='forgotPass']/div/button[@id='btnLogin']" findby="xpath" />
<control tofind="//button[contains(text(),'Log in')]" findby="xpath" />
<action command="Click" />
我认为上面几行代码有错误。
<control tofind="#bctr" findby="cssselector" />, this line you were trying to locate an element using its id, but "bctr" is not a id.
<control tofind=".bctr" findby="cssselector" />, this line you were trying to locate an element using its tag, but "bctr" is not a tag.
<control tofind="#btnLogin" findby="xpath" />, "#" does not apply to xpath syntax, I think. it only applies to css selector.
<control tofind="btnLogin" findby="id" />, I am a bit confused here, why did you assign findby with 'id'?
<control tofind="//*[@button='btnLogin']" findby="xpath" />, 'btnLogin' is not a value for 'button', button is its tag name, you should have written //*button[@id='btnLogin']
<control tofind="//*[@id='btnLogin']" findby="xpath" />
<control tofind="//*[@id='btnLogin']" findby="xpath" />, why did you use this line twice in a row?
<control tofind="//div[@class='bctr']" findby="xpath" />, this would probably work, but it depends on whether you would uniquely identify this button or not.
<control tofind="//button[@id='btnLogin']" findby="xpath" />, this would work, but it depends on whether you would uniquely identify this button or not as well.
<control tofind="//*[@class='forgotPass']/div/button[@id='btnLogin']" findby="xpath" />, this would not work, as 'forgotPass' does not have a match, I think what you meant is [starts-with(@class,'forgotPass')], which reads looking for an element that has a class attribute starts with "forgotPass".
<control tofind="//button[contains(text(),'Log in')]" findby="xpath" />, this would work, but you need to verify if this method is supported by your selenium driver.
这是一个有用的链接。 http://scraping.pro/res/xpath-cheat/xpath_css_dom_recipes.pdf