其中有一片文章提到了xpath元素定位,但是該文章中有些并不能適應(yīng)一些特殊與個(gè)性化的場(chǎng)景。在文本中提供xpath元素的定位篇,你一定能在這里找到你需要的解決辦法。
	  第一種方法:通過(guò)路徑做定位(相信大家不會(huì)使用這種方式)
	  By.xpath("html/body/div/form/input")
	  By.xpath("//input")
	  第三種方法:通過(guò)元素索引定位
	  By.xpath("//input[4]")
	  第四種方法:使用xpath屬性定位(結(jié)合第2、第3中方法可以使用)
	  By.xpath("//input[@id='kw1']")
	  By.xpath("//input[@type='name' and @name='kw1']")
	  第五種方法:使用部分屬性值匹配(強(qiáng)大的方法)
	  By.xpath("//input[start-with(@id,'nice')
	  By.xpath("//input[ends-with(@id,'很漂亮')
	  By.xpath("//input[contains(@id,'那么美')]")
	  第6種方法:使用xpath軸(未曾使用)
	  希望,以上這些方法,能夠幫助到你。