我期待得到以下帮助。
我正在使用Xpaths在Chrome中为应用程序执行测试自动化。它运作良好。但是现在我需要使用相同的套件在IE 11中进行跨浏览器测试。
目前使用2.39 IE Webdriver for Selenium。我可以打开浏览器,但我的X路径有我的脚本,不能在IE 11中使用X路径。
所以这是我的问题
PS:我使用Capabilities Ignorezoomsetting为true,要求将窗口焦点设置为true,将本机元素设置为false for Internet Explorer
先谢谢
Html代码:
<html><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="white">
<link rel="shortcut icon" href="favicon.ico?v=2" type="image/x-icon">
<title>-</title>
<style data-styled-components=""></style></head>
<body>
<div id="modal"></div>
<div id="app"><div class="Flex-kFpfAw ixXCQP" overflow="auto" display="flex" width="100%"><div class="NavBarIndicator__NavBarIndicatorHtml-ibzzfP jRSwXJ"><div class="NavBarIndicator__Indicator-eUunBf jITNXW"></div><div class="NavBarIndicator__IndicatorSettings-kgrEUt cPoXyp"></div></div><div class="Header__HeaderWrapper-cPhxZP hLpJId"><img class="_NavBarMenu__MenuIcon-gZnMef eTeQZD" src="/assets/images/menu.png"><div class="Flex-kFpfAw eaWcQg" width="100%" height="100%" display="flex"><div class="Flex-kFpfAw iuKZOD" width="200px" display="flex"><div class="Flex-kFpfAw cHydLU" cursor="pointer" width="0 auto" display="flex"><a href="new-client" style="text-decoration: none;"><a class="AnchorLink__LinkWrapper-kpcMPo iKDWLW" color="#696969" font-size="14px" font-family="OpenSans">New Client</a></a></div><div class="Flex-kFpfAw cHydLU" cursor="pointer" width="0 auto" display="flex"><a class="AnchorLink__LinkWrapper-kpcMPo cJfTFc" color="#696969" font-size="14px" font-family="OpenSans">Existing Client</a></div></div></div></div><div class="Flex-kFpfAw eXWVrO" width="100%" display="flex"><div class="Flex-kFpfAw kgPlre" display="flex" width="100%"><div class="Accordion__AccordionContainer-lhzlfC jUObfx" name="basicDetailsAccordion" width="100%"><div class="Accordion__ActiveBar-fUxxNn dIFKrP" width="100%"></div><div class="Accordion__TopBarContainer-eqOfxK dbwwMy"><div class="Accordion__HeaderText-btWcFX kpnLnx">BASICS</div><div class="Accordion__ArrowContainer-jgNnsk joAlIe"></div></div><div class="Accordion__ContentContainer-bNGADI dUFUSp"><div class="Grid__Row-eThVWD keRYro"><div class="Grid__Column-dzIFTK cYStlC"><div class="Dropdown__DropdownContainer-iuXXkE eGcMOz" value=""><input class="Dropdown__InputField-XdsGe saBoZ" placeholder="" value=""><div class="Dropdown__FloatingLabel-dAuMht kobteq" value="">Title</div><div class="Dropdown__baseIconStyle-hZrHDI dGulpi" value=""></div><div class="Dropdown__DescOrErrorContainer-CVXZE cVVTfy"></div><div class="Dropdown__DropdownItemsContainer-ePnZKJ jIlnqS"></div></div></div><div class="Grid__Column-dzIFTK cYStlC"><div class="TextField__Wrapper-iMDdAX jeqFJ" value=""><input class="TextField__Input-eZJwmJ hjrRW" type="text" value=""><div class="TextField__Label-hiPeUU dbpoGq" value="">Christian Name</div><span class="TextField__Text-jWKysX jCdXZa"></span><div></div></div></div></div><div class="Grid__Row-eThVWD keRYro"><div class="Grid__Column-dzIFTK cYStlC"><div class="TextField__Wrapper-iMDdAX jeqFJ" value=""><input class="TextField__Input-eZJwmJ hjrRW" type="text" value=""><div class="TextField__Label-hiPeUU dbpoGq" value="">Given Name</div><span class="TextField__Text-jWKysX jCdXZa"></span><div></div></div></div><div class="Grid__Column-dzIFTK cYStlC"><div class="TextField__Wrapper-iMDdAX jeqFJ" value=""><input class="TextField__Input-eZJwmJ hjrRW" type="text" value=""><div class="TextField__Label-hiPeUU dbpoGq" value="">Surname *</div><span class="TextField__Text-jWKysX jCdXZa"></span><div></div></div></div></div><div class="Grid__Row-eThVWD keRYro"><div class="Grid__Column-dzIFTK cYStlC"><div class="Dropdown__DropdownContainer-iuXXkE eGcMOz" value=""><input class="Dropdown__InputField-XdsGe saBoZ" placeholder="" value=""><div class="Dropdown__FloatingLabel-dAuMht kobteq" value="">Marital Status</div><div class="Dropdown__baseIconStyle-hZrHDI dGulpi" value=""></div><div class="Dropdown__DescOrErrorContainer-CVXZE cVVTfy"></div><div class="Dropdown__DropdownItemsContainer-ePnZKJ jIlnqS"></div></div></div><div class="Grid__Column-dzIFTK cYStlC"><div class="TextField__Wrapper-iMDdAX jeqFJ" value=""><input class="TextField__Input-eZJwmJ hjrRW" type="date" value=""><div class="TextField__Label-hiPeUU dbpoGq" value=""></div><span class="TextField__Text-jWKysX jCdXZa"></span><div></div></div></div></div><div class="Grid__Row-eThVWD keRYro"><div class="Grid__Column-dzIFTK cYStlC"><div class="Dropdown__DropdownContainer-iuXXkE eGcMOz" value=""><input class="Dropdown__InputField-XdsGe saBoZ" placeholder="" value=""><div class="Dropdown__FloatingLabel-dAuMht kobteq" value="">Nationality</div><div class="Dropdown__baseIconStyle-hZrHDI dGulpi" value=""></div><div class="Dropdown__DescOrErrorContainer-CVXZE cVVTfy"></div><div class="Dropdown__DropdownItemsContainer-ePnZKJ jIlnqS"></div></div></div><div class="Grid__Column-dzIFTK cYStlC"><div class="TextField__Wrapper-iMDdAX jeqFJ" value=""><input class="TextField__Input-eZJwmJ hjrRW" type="text" value=""><div class="TextField__Label-hiPeUU dbpoGq" value="">NRIC or Passport number</div><span class="TextField__Text-jWKysX jCdXZa"></span><div></div></div></div></div><div class="Grid__Row-eThVWD keRYro"><div class="Grid__Column-dzIFTK cYStlC"><div class="Flex-kFpfAw hhPbtN" height="80px" value="maleRadio" display="flex" width="100%"><div class="Radio__Header-iLHfxq epdwGX">Gender</div><div class="Flex-kFpfAw kgPlre" display="flex" width="100%"><div class="Radio__Child-iQExMs iJGsOb" value="maleRadio">Male</div><div class="Radio__Child-iQExMs gETYuF" value="femaleRadio">Female</div></div></div></div><div class="Grid__Column-dzIFTK cYStlC"><div class="Flex-kFpfAw hhPbtN" height="80px" value="smokerYesRadio" display="flex" width="100%"><div class="Radio__Header-iLHfxq epdwGX">Smoker</div><div class="Flex-kFpfAw kgPlre" display="flex" width="100%"><div class="Radio__Child-iQExMs iJGsOb" value="smokerYesRadio">Yes</div><div class="Radio__Child-iQExMs gETYuF" value="smokerNoRadio">No</div></div></div></div></div></div></div></div><div class="Flex-kFpfAw kgPlre" display="flex" width="100%"><div class="Accordion__AccordionContainer-lhzlfC iOrkBi" name="contactDetailsAccordion" width="100%"><div class="Accordion__ActiveBar-fUxxNn dRpCWJ" width="100%"></div><div class="Accordion__TopBarContainer-eqOfxK dbwwMy"><div class="Accordion__HeaderText-btWcFX kpnLnx">CONTACT</div><div class="Accordion__ArrowContainer-jgNnsk cmIaNs"></div></div></div></div><div class="Flex-kFpfAw kgPlre" display="flex" width="100%"><div class="Accordion__AccordionContainer-lhzlfC iOrkBi" name="educationDetailsAccordion" width="100%"><div class="Accordion__ActiveBar-fUxxNn dRpCWJ" width="100%"></div><div class="Accordion__TopBarContainer-eqOfxK dbwwMy"><div class="Accordion__HeaderText-btWcFX kpnLnx">EDUCATION & OCCUPATION</div><div class="Accordion__ArrowContainer-jgNnsk cmIaNs"></div></div></div></div><div class="Flex-kFpfAw kgPlre" display="flex" width="100%"><div class="Accordion__AccordionContainer-lhzlfC iOrkBi" name="othersAccordion" width="100%"><div class="Accordion__ActiveBar-fUxxNn dRpCWJ" width="100%"></div><div class="Accordion__TopBarContainer-eqOfxK dbwwMy"><div class="Accordion__HeaderText-btWcFX kpnLnx">OTHERS</div><div class="Accordion__ArrowContainer-jgNnsk cmIaNs"></div></div></div></div><div class="Flex-kFpfAw kgPlre" display="flex" width="100%"><div class="Flex-kFpfAw iJaRwj" width="100%" display="flex"><a href="/client"><input class="Button__ButtonHtml-kIBguK eybnQU" type="submit" value="Back"></a><div class="Space-fYzrqg kpkBkk"></div><input class="Button__ButtonHtml-kIBguK kkGQYo" type="submit" value="Next"></div></div></div><div class="Overlay__OverlayHtml-fHbRtE iMIwlR"></div><div class="NavBarIndicator__NavBarIndicatorHtml-ibzzfP jRSwXJ"><div class="NavBarIndicator__Indicator-eUunBf jITNXW"></div><div class="NavBarIndicator__IndicatorSettings-kgrEUt cPoXyp"></div></div><div class="NavBar__NavBarHtml-AmdPv dLHKZS" color="red"><div class="NavBar__CloseButton-bbtqJM jXPpvT"><img class="NavBar__CloseIcon-kbJaLK hqvvWp" src="/assets/images/leftArrow.png"></div><a id="new-proposal" href="/client" style="text-decoration: none;"><div class="_NavBarButton__NavBarButtonHtml-jFBQvK hjgrnZ"><img class="_NavBarButton__NavBarIcon-koVGUP gjfdcG" src="/assets/images/addActive.png"><br><div class="_NavBarButton__Label-deFDME llMpjg">New Proposal</div></div></a><a href="/transactions" style="text-decoration: none;"><div class="_NavBarButton__NavBarButtonHtml-jFBQvK hjgrnZ"><img class="_NavBarButton__NavBarIcon-koVGUP gjfdcG" src="/assets/images/transaction.png"><br><div class="_NavBarButton__Label-deFDME ofuLs">Transactions</div></div></a><a href="/opportunity" style="text-decoration: none;"><div class="_NavBarButton__NavBarButtonHtml-jFBQvK hjgrnZ"><img class="_NavBarButton__NavBarIcon-koVGUP gjfdcG" src="/assets/images/opportunity.png"><br><div class="_NavBarButton__Label-deFDME ofuLs">Opportunity</div></div></a><a href="/settings" style="text-decoration: none;"><div class="NavBar__SettingsButton-gpFICj jHbjOK"><img class="NavBar__NavBarIcon-blvkXP fBFcQi" src="/assets/images/setting.png"><br><div class="NavBar__Label-eCmPLc cIziCb">Settings</div></div></a></div></div></div>
<script type="text/javascript" src="/assets/js/vendors~main.50b6700db1e18bf97471.js"></script><script type="text/javascript" src="/assets/js/main.50b6700db1e18bf97471.js"></script>
<!-- version: PROD --></body></html>
答案 0 :(得分:0)
答案是否。使用 cssSelector ,有时 xpath 可能会有效,如果它不是太绝对的话。可能是亲戚会更轻松地完成工作。
IE 中没有 xpath 的原生支持,再次使用 cssSelector 来克服此问题。
我从所有论坛都了解到使用 CSS 而不是X路径,我也可以这样做但只是要理解Chrome和IE 11中的X路径是一样的。
最后我想了解一个基本的事情,当我们说在浏览器中没有出现Xpath原生支持时 - 我们的意思是什么
这意味着IE引擎没有任何针对xpath的东西,IE必须使用第三方才能与xpath相处。
希望这会有所帮助。