Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Java解决Selenium注销Facebook的问题_Java_Facebook_Selenium_Xpath - Fatal编程技术网

如何使用Java解决Selenium注销Facebook的问题

如何使用Java解决Selenium注销Facebook的问题,java,facebook,selenium,xpath,Java,Facebook,Selenium,Xpath,关于如何使用Selenium注销Facebook,我到处都在搜索。我仔细研究了有关StackOverflow的问题,以及许多其他使用Selenium的网站,尽管没有成功。我正在学习Selenium,在遇到这个障碍之前,我一直认为它非常简单。无论我做什么,Selenium都不会注销Facebook。下面是我正在使用的代码。我很欣赏任何方向(我使用Firepath获得xpath地址): } 以下是返回的错误: Facebook PASSED: test1 PASSED: test2 FAILED:

关于如何使用Selenium注销Facebook,我到处都在搜索。我仔细研究了有关StackOverflow的问题,以及许多其他使用Selenium的网站,尽管没有成功。我正在学习Selenium,在遇到这个障碍之前,我一直认为它非常简单。无论我做什么,Selenium都不会注销Facebook。下面是我正在使用的代码。我很欣赏任何方向(我使用Firepath获得xpath地址):

}

以下是返回的错误:

Facebook
PASSED: test1
PASSED: test2
FAILED: test3
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"html/body/div[17]/div/div/div/div/div[1]/div/div/ul/li[16]/a/span/span"}
Command duration or timeout: 33 milliseconds
For documentation on this error, please visit:       http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:03:33'
System info: host: 'RLaptop', ip: '192.168.xx.x', os.name: 'Windows  10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_73'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false,   handlesAlerts=true, databaseEnabled=true, version=45.0.1, platform=WINDOWS,   nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true,   locationContextEnabled=true, browserName=firefox, takesScreenshot=true,  javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: c5781a63-5d20-4a55-9cd6-7cd70aa38165
*** Element info: {Using=xpath,    value=html/body/div[17]/div/div/div/div/div[1]/div/div/ul/li[16]/a/span/span}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)
at org.openqa.selenium.remote.RemoteWebElement.findElement(RemoteWebElement.java:198)
at org.openqa.selenium.remote.RemoteWebElement.findElementByXPath(RemoteWebElement.java:295)
at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
at org.openqa.selenium.remote.RemoteWebElement.findElement(RemoteWebElement.java:194)
at Testing.GetFacebookTitle.test3(GetFacebookTitle.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element:  {"method":"xpath","selector":"html/body/div[17]/div/div/div/div/div[1]/div/div/u l/li[16]/a/span/span"}
For documentation on this error, please visit:     http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11      19:03:33'
System info: host: 'RLaptop', ip: '192.168.xx.x', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_73'
Driver info: driver.version: unknown
at <anonymous   class>.FirefoxDriver.prototype.findElementInternal_(file:///C:/Users/Rozelle/App Data/Local/Temp/anonymous1905752364377844577webdriver-  profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10723)
at <anonymous  class>.FirefoxDriver.prototype.findChildElement(file:///C:/Users/Rozelle/AppData /Local/Temp/anonymous1905752364377844577webdriver- profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10735)
at <anonymous  class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/Rozelle/AppD ata/Local/Temp/anonymous1905752364377844577webdriver- profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12614)
at <anonymous  class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/Rozelle/AppDat a/Local/Temp/anonymous1905752364377844577webdriver- profile/extensions/fxdriver@googlecode.com/components/command- processor.js:12619)
at <anonymous  class>.DelayedCommand.prototype.execute/<(file:///C:/Users/Rozelle/AppData/Local/Temp/anonymous1905752364377844577webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12561)
Facebook
通过:测试1
通过:测试2
失败:test3
org.openqa.selenium.NoSuchElementException:无法定位元素:{“方法”:“xpath”,“选择器”:“html/body/div[17]/div/div/div/div/div[1]/div/div/ul/li[16]/a/span/span”}
命令持续时间或超时:33毫秒
有关此错误的文档,请访问:http://seleniumhq.org/exceptions/no_such_element.html
构建信息:版本:“2.52.0”,修订版:“4c2593c”,时间:“2016-02-11 19:03:33”
系统信息:主机:'RLaptop',ip:'192.168.xx.x',os.name:'Windows 10',os.arch:'x86',os.version:'10.0',java.version:'1.8.0_73'
驱动程序信息:org.openqa.selenium.firefox.FirefoxDriver
功能[{applicationCacheEnabled=true,rotatable=false,handlesAlerts=true,databaseEnabled=true,version=45.0.1,platform=WINDOWS,nativeEvents=false,acceptSslCerts=true,WebStorage Enabled=true,locationContextEnabled=true,browserName=firefox,takesScreenshot=true,javascriptEnabled=true,CSSSelectorEnabled=true}]
会话ID:c5781a63-5d20-4a55-9cd6-7cd70aa38165
***元素信息:{Using=xpath,value=html/body/div[17]/div/div/div/div[1]/div/div/ul/li[16]/a/span/span}
位于sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)
位于sun.reflect.NativeConstructorAccessorImpl.newInstance(未知源)
位于sun.reflect.delegatingConstructor或AccessorImpl.newInstance(未知源)
位于java.lang.reflect.Constructor.newInstance(未知源)
位于org.openqa.selenium.remote.ErrorHandler.CreateTrowable(ErrorHandler.java:206)
位于org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
位于org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
位于org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)
位于org.openqa.selenium.remote.RemoteWebElement.findElement(RemoteWebElement.java:198)
位于org.openqa.selenium.remote.RemoteWebElement.findElementByXPath(RemoteWebElement.java:295)
位于org.openqa.selenium.By$ByXPath.findElement(By.java:361)
位于org.openqa.selenium.remote.RemoteWebElement.findElement(RemoteWebElement.java:194)
在Testing.GetFacebookTitle.test3(GetFacebookTitle.java:47)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(未知源)
在sun.reflect.DelegatingMethodAccessorImpl.invoke处(未知源)
位于java.lang.reflect.Method.invoke(未知源)
位于org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
位于org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
位于org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
位于org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
位于org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
位于org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
位于org.testng.TestRunner.privateRun(TestRunner.java:774)
位于org.testng.TestRunner.run(TestRunner.java:624)
位于org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
在org.testng.SuiteRunner.runsequential上(SuiteRunner.java:354)
位于org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
运行(SuiteRunner.java:261)
位于org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
位于org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
在org.testng.testng.runSuitesSequentially上(testng.java:1215)
位于org.testng.testng.runSuitesLocally(testng.java:1140)
位于org.testng.testng.run(testng.java:1048)
位于org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
位于org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
位于org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)
原因:org.openqa.selenium.NoSuchElementException:无法定位元素:{“方法”:“xpath”,“选择器”:“html/body/div[17]/div/div/div/div/div[1]/div/div/u l/li[16]/a/span/span”}
有关此错误的文档,请访问:http://seleniumhq.org/exceptions/no_such_element.html
构建信息:版本:“2.52.0”,修订版:“4c2593c”,时间:“2016-02-11 19:03:33”
系统信息:主机:'RLaptop',ip:'192.168.xx.x',os.name:'Windows 10',os.arch:'x86',os.version:'10.0',java.version:'1.8.0_73'
驱动程序信息:驱动程序。版本:未知
at.FirefoxDriver.prototype.findElementInternal_(file:///C:/Users/Rozelle/App 数据/本地/临时/匿名1905752364377844577WebDriver-配置文件/扩展/fxdriver@googlecode.com/组件/驱动程序组件(js:10723)
at.FirefoxDriver.prototype.findChildElement(file:///C:/Users/Rozelle/AppData /本地/临时/匿名1905752364377844577WebDriver-配置文件/扩展/fxdriver@googlecode.com/组件/驱动程序组件(js:10735)
at.DelayedCommand.prototype.executeInternal\uh(file:///C:/Users/Rozelle/AppD ata/Local/Temp/anonymous1905752364377844577webdriver-配置文件/扩展/fxdriver@googlecode.com/组件/命令处理器(js:12614)
at.DelayedCommand.prototype.executeInternal_(file:///C:/Users/Rozelle/AppDat a/Local/Temp/anonymous1905752364377844577webdriver-配置文件/扩展/fxdriver@googlecode.com/components/command-processor.js:12619)
在.DelayedCommand.prototype.execute/而不是此行

lstitem.findElement(By.xpath("html/body/div[17]/div/div/div/div/div[1]/div/div/ul/li[16]/a/span/span")).click();
使用下面的行,它应该工作

driver.findElement(By.partialLinkText("Log Out")).click();
而不是这条线

lstitem.findElement(By.xpath("html/body/div[17]/div/div/div/div/div[1]/div/div/ul/li[16]/a/span/span")).click();
使用下面的行,它应该工作

driver.findElement(By.partialLinkText("Log Out")).click();

当您在Facebook的下拉列表上执行单击操作以显示注销表单时,页面将执行Javascript以将下拉HTML附加到D