我经常遇到无法右键单击以检查其xpath或CSS的元素。
我想问一下还有哪些其他方式可以点击这些元素?
答案 0 :(得分:0)
如果要获取元素定位器,但右键单击不起作用,请尝试以下操作。
首先,通过按 Ctrl + Shift + I 打开开发工具窗口。 如果那不起作用,则首先打开开发工具,然后加载页面。
打开开发工具后,单击“选择元素”工具,开发工具左侧的打印机图标。您可以通过按 Ctrl + Shift + C 直接获取此工具。
然后将鼠标悬停在要获取定位器的元素上。该元素将在DOMs中的elements标签中被选中。右键单击DOM中的元素。 然后从上下文菜单转到复制->复制选择器(用于CSS选择器)或复制XPath(用于XPath)。 现在,您已经在剪贴板中找到了该元素的定位符。
答案 1 :(得分:0)
您可以使用private class NickName
{
public string Nick { get; set; }
public int Value { get; set; }
}
private BindingSource source = null;
private List<NickName> NickNames = null;
private void Form1_Load(object sender, EventArgs e)
{
NickNames = new List<NickName>();
NickNames.AddRange(new[] {
new NickName() { Nick = "", Value = 0 },
new NickName() { Nick = "Andrea", Value = 10 },
new NickName() { Nick = "Arnold", Value = 20 },
new NickName() { Nick = "Barbara", Value = 30 },
new NickName() { Nick = "Billy", Value = 40 },
new NickName() { Nick = "Clint", Value = 50 },
new NickName() { Nick = "Cindy", Value = 60 },
});
source = new BindingSource();
source.DataSource = NickNames;
txtAutoComp.AutoCompleteMode = AutoCompleteMode.Suggest;
txtAutoComp.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtAutoComp.AutoCompleteCustomSource.AddRange(NickNames.Select(n => n.Nick).ToArray());
Binding textBind = new Binding("Text", source, "Nick", true, DataSourceUpdateMode.OnPropertyChanged);
textBind.Parse += (s, evt) => {
source.CurrencyManager.Position = NickNames.FindIndex(1, r => r.Nick.Equals(evt.Value));
};
txtAutoComp.DataBindings.Add(textBind);
lblNickName.DataBindings.Add(new Binding("Text", source, "Nick"));
lblNickValue.DataBindings.Add(new Binding("Text", source, "Value"));
}
private void btnFindNick_Click(object sender, EventArgs e)
{
FindNick(txtAutoComp.Text);
}
private void txtAutoComp_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter) {
e.SuppressKeyPress = true;
FindNick(txtAutoComp.Text);
}
}
void FindNick(string partialName)
=> this.source.CurrencyManager.Position = NickNames.FindIndex(
1, r => r.Nick.Contains(partialName)
);
,它将通过选择要检查的元素来打开devtools。只需将鼠标光标移到该元素上并单击,它就会将devtools中的html视图滚动到正确的位置。
或者,您可以按Full_Freq<-data.frame(NA_INC = c(11.8, 10.1, 11.9, 18.8, 17.8, 1.7, 1.7, 1.8, 3.5, .001),
NA_EXC = c(54.9, 38.6, 27.9, 34.7, 36.1, 2.3, 2.3, 2.8, 8.4, 100.0),
code = c("RI1 - R1,C1,A,G,R", "RI2 - R1,C1,A,E,R", "RC1 - R1,C1,A,E,R",
"RP3 - R2,C2,B1L1,BGLG,BRLR", "RP4 - R1,C1,A,P,O", "RM1 A - R3,C3,M1D1L1,MWDELE,MRDRLR",
"RM1 B - R3,C4,M2D1L1,MWDPLP,MRDRLO","RM2 - R3,C3,M1D1L1,MWDGLG,MRDRLR",
"RM3 - R3,C3,M1D1L1,MWDGLG,MRDRLR","RM4 - R1,C1,A,P,R"))
ggplot(Full_Freq) +
geom_col(aes(x = code, y = NA_EXC), fill = "gray", colour = "black") +
geom_col(aes(x = code, y = NA_INC), fill = "black", colour = "black")+
ylab("Percentage")+
xlab("")+
ggtitle("Tooth and Full Phenotype Code")+
theme_classic()+
theme(plot.title = element_text(hjust= 0.5))+
theme(axis.text.x = element_text(angle = 90, vjust=0.5))
并切换选择要检查的元素的按钮(devtools的左上角)。
答案 2 :(得分:0)
Control + Shift + C 或F12将为您打开开发工具,然后您可以在浏览器上单击光标模式。
答案 3 :(得分:0)
HTML DOM中没有很多元素/控件,即,您不能右键单击该元素以通过google-chrome-devtools
检查它们的xpath。三种最常见的此类元素/控件如下:
无法在DOM Tree中跟踪这些通知。在这里,您将找到关于How to allow or deny notification geo-location microphone camera pop up
的相关讨论
此消息也不能位于DOM Tree中。在这里,您将找到有关How to handle below Internet Explorer popup “Are you sure you want to leave this page?” through Selenium
的详细讨论