Closed shaheenashaik closed 9 years ago
//import java.io.IOException; //import org.apache.bcel.generic.Select; import org.openqa.selenium.support.ui.Select; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; //import org.testng.annotations.AfterClass; //import org.testng.annotations.BeforeClass; //import org.testng.annotations.BeforeTest; //import org.testng.annotations.Test; public class Big_Basket { public static void main(String []args){ WebDriver driver; driver=new FirefoxDriver(); driver.manage().window().maximize(); driver.get("http:\\www.google.com"); System.out.println("The webpage name is :"+ driver.getTitle()); driver.findElement(By.id("lst-ib")).sendKeys("Big Basket"); driver.findElement(By.name("btnG")).click(); driver.findElement(By.xpath(".//*[@id='rso']/div[1]/div/table/tbody/tr[4]/td[1]/div/span/h3/a")).click(); System.out.println("The webpage name is :"+ driver.getTitle()); driver.get("http://bigbasket.com/"); WebElement element=driver.findElement(By.id("ftv-city-selectboxdiv")); Select se=new Select(element); se.selectByVisibleText("Bangalore"); driver.findElement(By.id("area_selection")).clear(); WebElement element1=driver.findElement(By.id("area_selection")); Select se1=new Select(element1); se1.selectByVisibleText("Jayanagar 4 Block, Bengaluru, Karnataka, India"); driver.findElement(By.id("area_selection")).sendKeys("Jayanagar 4 Block, Bengaluru, Karnataka, India"); driver.findElement(By.id("area_selection")).equals("Jayanagar 4 Block, Bengaluru, Karnataka, India"); driver.findElement(By.xpath("#set_visitor_address")).click(); driver.findElement(By.id("id_q")).clear(); driver.findElement(By.id("id_q")).sendKeys("Apples"); driver.findElement(By.xpath("//*[@id='auto_search']/div/form/input[2]")).click(); driver.close(); driver.quit(); } }
my error is :+1:
The webpage name is :Google Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":".//*[@id='rso']/div[1]/div/table/tbody/tr[4]/td[1]/div/span/h3/a"} Command duration or timeout: 23 milliseconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52' System info: host: 'shaheena-PC', ip: '192.168.0.10', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_51' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=42.0, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID: bc42f0ec-5a72-4787-8f1b-b585a36de4a0 *** Element info: {Using=xpath, value=.//*[@id='rso']/div[1]/div/table/tbody/tr[4]/td[1]/div/span/h3/a} 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:647) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:353) at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:490) at org.openqa.selenium.By$ByXPath.findElement(By.java:361) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:345) at Big_Basket.main(Big_Basket.java:29) Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":".//*[@id='rso']/div[1]/div/table/tbody/tr[4]/td[1]/div/span/h3/a"} For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52' System info: host: 'shaheena-PC', ip: '192.168.0.10', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_51' Driver info: driver.version: unknown at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:///C:/Users/shaheena/AppData/Local/Temp/anonymous518124023766071695webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10659) at <anonymous class>.FirefoxDriver.prototype.findElement(file:///C:/Users/shaheena/AppData/Local/Temp/anonymous518124023766071695webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10668) at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/shaheena/AppData/Local/Temp/anonymous518124023766071695webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12534) at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/shaheena/AppData/Local/Temp/anonymous518124023766071695webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12539) at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/shaheena/AppData/Local/Temp/anonymous518124023766071695webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12481)
i used all locators type to find element but again it showing same error
i can't see the use of htmlelements framework here, please post your question on stackoverflow
my error is :+1: