Web Scraper with Selenium - java

I'm trying to do a scraping exercise with Selenium, but I'm having a few problems.
Here is my code:
package ScraperPakage;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
import java.util.List;
public class ScraperClass {
public static void main(String[] args) {
//Create a new instance of Firefox Browser
System.setProperty("webdriver.gecko.driver", "C:\\Users\\xxxx\\Selenium\\geckodriver-v0.10.0-win64\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
//Open the URL in firefox browser
driver.get("http://www.budgettravel.ie");
// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());
List<WebElement> titles = driver.findElements(By.cssSelector("div.travelOfferList"));
for (int j = 0; j < titles.size(); j++) {
System.out.println( "\t - " + titles.get(j).getText() ) ;
}
driver.quit();
}
}
The code returns the list of offer holidays, but ends with a list of errors that I don't know how to resolve.
Here is the output:
JavaScript warning: resource://cck2/CCK2.jsm, line 998: unreachable code after return statement
JavaScript warning: resource://cck2/Preferences.jsm, line 556: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create
1472551987508 Marionette INFO Listening on port 62410
JavaScript warning: https://normandy.cdn.mozilla.net/static/bundles/selfrepair-068962304d04a2173e88.94ed0f93a4f3.js, line 11002: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create
Page title is: Cheap Holidays 2016/ 2017, Cheap Sun Holidays from Dublin, All Inclusive Sun Package Holidays from Ireland, Cheap Last Minute Holidays & Deals, All Inclusive Late Holiday Deals - Budget Travel
- Last Minute Deals
Where
When
Nights
From
Costa Blanca
21 Sep
7
€185pp
[ ... REST OF THE LIST ...]
Costa Dorada
22 Oct
7
€146pp
[Child 14212] WARNING: pipe error: 232: file c:/builds/moz2_slave/m-rel-w32-00000000000000000000/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 487
[Child 14212] ###!!! ABORT: Aborting on channel error.: file c:/builds/moz2_slave/m-rel-w32-00000000000000000000/build/src/ipc/glue/MessageChannel.cpp, line 2027
[NPAPI 13576] ###!!! ABORT: Aborting on channel error.: file c:/builds/moz2_slave/m-rel-w32-00000000000000000000/build/src/ipc/glue/MessageChannel.cpp, line 2027
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: 'unknown', revision: '2aa21c1', time: '2016-08-02 14:59:43 -0700'
System info: host: 'xxxx', ip: 'xxxx', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_101'
Driver info: driver.version: RemoteWebDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, appBuildId=20160623154057, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, browserVersion=47.0.1, platformVersion=6.1, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=Firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=Windows_NT, device=desktop}]
Session ID: 3ad95378-01d1-4c6c-a3ce-24f992fb5289
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:670)
[... OTHER LINES LIKE THE LINE JUST ABOVE ...]
Also, the are two windows opening with 'Plugin Container for Firefox has stopped working'
Problem signature:
Problem Event Name: APPCRASH
Application Name: plugin-container.exe
Application Version: 47.0.1.6018
Application Timestamp: 576c9637
Fault Module Name: mozglue.dll
Fault Module Version: 47.0.1.6018
Fault Module Timestamp: 576c85ba
Exception Code: 80000003
Exception Offset: 0000f02b
OS Version: 6.1.7601.2.1.0.256.4
Locale ID: 6153
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
Any ideas why I'm getting the errors at the end and the windows opening at the end.
Thanks

Related

Selenium/Java - Cannot locate option with index

I am practicing selenium with practiceautomation.com site. I have problem with registration - my selector cannot locate option with index.
code:
Select yearSelector = new Select(driver.findElement(By.id("years")));
yearSelector.selectByIndex(2000);
And I got something like:
org.openqa.selenium.NoSuchElementException: Cannot locate option with index: 2000
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'DESKTOP-NN5LV43', ip: '192.168.0.2', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '10.0.1'
Driver info: driver.version: unknown
It is strange, because I use also
Select dateSelector = new Select(driver.findElement(By.id("days")));
dateSelector.selectByIndex(15);
And everything works fine and the day on the list is normally selected
Picture:
Year
As you can see, years are visible.
You try to select by index 2000 and errors says no option with index 2000. Maybe you want to select by value?
Select yearSelector = new Select(driver.findElement(By.id("years")));
yearSelector.selectByValue("2000");
public void selectByIndex(int index)
The above method select the option at the given index. This is done by examining the "index" attribute of an element, and not merely by counting.If no matching option elements are found then NoSuchElementException is thrown
Check for index attribute in html with value as 2000 it should not be there so try with
selector.selectByIndex(1); // see first visible year is selected or not

Selenium : The browser is getting opened but not able to get URL in the browser

OS:Windows 10
Execution Environment : JavaSE-1.8 (jre1.8.0_144)
JARs and class folders on build path:
client-combined-3.6.0-sources.jar
client-combined3.6.0.jar
selenium-server-standalone-3.6.0.jar
Browser:
FireFox 56.0
Code Snippet:
System.setProperty("webdriver.firefox.marionette","C:/Users/admin/Downloads/geckodriver-v0.11.1-win32/geckodriver.exe");
WebDriver driver = new FirefoxDriver ();
driver.get("https://www.facebook.com");
Error:
Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting 45 seconds for Firefox to start.
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:26.402Z'
System info: host: 'ADMIN-PC', ip: '192.168.1.6', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_144'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.XpiDriverService.waitUntilAvailable(XpiDriverService.java:112)
at org.openqa.selenium.firefox.XpiDriverService.start(XpiDriverService.java:97)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:217)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:140)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:98)
at FacebookFriends.main(FacebookFriends.java:18)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:45149/hub/status] to be available after 45005 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
at org.openqa.selenium.firefox.XpiDriverService.waitUntilAvailable(XpiDriverService.java:110)
... 8 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(Unknown Source)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:147)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
... 9 more
First of all You are using a little bit old version of gecko driver. The newest from: https://github.com/mozilla/geckodriver/releases
Then You need to set up system property with:
File gecko = new File("C:/Users/admin/Downloads/geckodriver-v0.19.0-win32/geckodriver.exe");
System.setProperty("webdriver.gecko.driver", gecko.getAbsolutePath());
If You really want to use marionette check answers on: Difference between webdriver.firefox.marionette & webdriver.gecko.driver
I haved this error for 2 days, the solution for me was in Set.Plataform put Platafor.ANY or Plataform.Windows because Plataform.WIN10 not worked, marionette wasn't necessary and I added and neether works, only works this. I hope this helps someone else:
public class Main {
public static RemoteWebDriver driver;
public static void main(String[] args) throws MalformedURLException {
System.setProperty("webdriver.gecko.driver", "D:/Lib/geckodriver.exe");
DesiredCapabilities desiredCapabilities = new DesiredCapabilities().firefox();
desiredCapabilities.setPlatform(Platform.ANY);
desiredCapabilities.setBrowserName("firefox");
driver = new RemoteWebDriver(new URL("http://172.20.19.182:5557/wd/hub"), desiredCapabilities);
driver.navigate().to("http://www.google.com");
driver.findElementByName("q").sendKeys("execute automation");
driver.findElementByName("q").sendKeys(Keys.ENTER);
driver.close();
// write your code here
}
}
You can also try using double \\ in the path of the geckodriver.
Also instead of using :
System.setProperty(
"webdriver.firefox.marionette",
"C:/Users/admin/Downloads/geckodriver-v0.11.1-win32/geckodriver.exe");
Can you try using
System.setProperty(
"webdriver.gecko.driver",
"C:\\Users\\admin\\Downloads\\geckodriver-v0.11.1-win32\\geckodriver.exe");
Title : Problem Resolved
Solution Accepted :
- Use latest version of gecko driver
Code Used
- System.setProperty("webdriver.gecko.driver","C:\Marionette\geckodriver_1.exe" );

Scroll and click - Not working for both Android and iOS on Appium tool with selenium java

I am trying to scroll and its not working for both Android and iOS, Can you please help me on this.
Look forward to hear back from you.
Did try with ScrollTO and ScrollToExact as both of them are deprecated now, so did try with this:
String str = "CADILLAC";
driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(\""+str+"\").instance(0))").click();
Still does not work.
Did go through many blogs , videos , course content and material no one has explained or there a specific solution on how to handle this
Did try with below,still gets the error
org.openqa.selenium.WebDriverException:
driver.findElementByAndroidUIAutomator("UiSelector().resourceId(\"current_value_tv\").text(\"All Makes\")").click();
driver.findElementByAndroidUIAutomator("UiSelector().className(\"android.widget.TextView\").text(\"AUSTIN HEALEY\")").click();
org.openqa.selenium.WebDriverException: An unknown server-side error
occurred while processing the command. (WARNING: The server did not
provide any stacktrace information)
Command duration or timeout: 45 milliseconds
Build info: version: '2.45.0', revision: '32a636c', time: '2015-03-05 22:01:35'
System info: host: 'NCA1026471', ip: '192.168.56.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version:
'1.8.0_91'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{app=C:\Appium\workspace\Lokesh\app\app-release.apk,
appPackage=au.com.carsguide, rotatable=true,
networkConnectionEnabled=true, noReset=true, warnings={},
handlesAlerts=true, deviceName=Carsguide Product, version=0.17.0,
platform=ANDROID, appActivity=au.com.carsguide.activity.HomeActivity,
desired= {app=C:\Appium\workspace\Lokesh\app\app-release.apk,
appPackage=au.com.carsguide,
appActivity=au.com.carsguide.activity.HomeActivity, noReset=true,
platformVersion=5.0, browserName=, platformName=Android,
deviceName=Carsguide Product, device=Android}, acceptSslCerts=true,
platformVersion=21, automationName=selendroid, browserName=selendroid,
takesScreenshot=true, javascriptEnabled=true, platformName=android,
device=Android}]
Session ID: e90cac4d-38aa-99fd-2dd2-70cc09a0e717
*** Element info: {Using=-android uiautomator, value=UiSelector().resourceId("current_value_tv").text("All Makes")}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
you can try this below code, i was trying this code on settings page..
AppiumDriver driver = new AndroidDriver(new URL(""), cap1);
driver.scrollTo("About phone");
Pass the String which is present in the bottom of your app page.
driver.scrollTo("Enter your value");
Use appropriate wait Statements.
use driver.swipe instead of driver.scroll
http://automationbyharsh.blogspot.in/
visit this blog to get full documentation of swipe method for Android and IOS.
scrollTO method is not consistent in appium for android apps. so try the following.
go till model listing page
try the below code snippet , This was for flipkart app
it may help you with your app
driver.findElementById("com.flipkart.android:id/search_autoCompleteTextView").sendKeys("Reebok Shoes" +"\n");
Thread.sleep(8000);
Dimension size = driver.manage().window().getSize();
System.out.println(size);
int Starty=(int)(size.height*0.90);
int Endy=(int)(size.height*0.10);
int Startx=(int)(size.width*0.50);
WebElement ele_item = driver.findElementByClassName("android.widget.TextView");
Thread.sleep(3000);
do
{
List<WebElement> ele_item2 = driver.findElementsByXPath("//*[#index='2'][#text='Reebok SPEED XT Running Shoes'][#class='android.widget.TextView']");
int size2 = ele_item2.size();
System.out.println(size2);
if(size2>0)
{
driver.findElementByXPath("//*[#index='2'][#text='Reebok SPEED XT Running Shoes'][#class='android.widget.TextView']").click();
break;
}
driver.swipe(Startx, Starty, Startx, Endy, 1000);
Thread.sleep(2000);
} while(ele_item.isDisplayed()==true);

WebDriverException: unknown error: cannot determine loading status from timeout: Timed out receiving message from renderer: 60 using Selenium and Java

In my Java project I am using Selenium for web automation. I am using chromedriver v2.20 executable. First "ChromeDriverService" is initialised and that is used to create ChromeDriver like, "new ChromeDriver(service, capabilities);". Also I used BrowserMobProxy to capture all web requests.
In my test I navigate to some URLs multiple times, after each navigation driver implicitly waits for few seconds, then polls result.
But while Execution it gives me timeout Exception.
In my research I came across solutions which are not working for me:
Instead of implicitlyWait use Thread.sleep
Replace new RemoteWebDriver(service.getUrl(), capabilities); by new ChromeDriver(service, capabilities);
After new ChromeDriver(...), wait for 1 sec using Thread.sleep(1000);
Can anyone please tell me why this error occurs ? how to handle this ?
ShouldPostToServerTest.java:
#Test
public void setTest() throws Exception {
for (int i = 0; i < 3; i++) {
nav();
poll();
}
}
private void nav() {
String[] navTo = {"http://www.bestbuy.com","http://www.amazon.com"};
for (int n = 0; n < 30 / navTo.length; n++) {
for (String url : navTo) {
chrome.navigateTo(url);
chrome.waitFor(5000);
}
}
}
private void poll() {
int pollInterval = 1000;
int remaining = 120 * 1000;
boolean found = false;
while (remaining > 0) {
if (found) // populateResult(), omitted for now.
break;
chrome.waitFor(pollInterval);
remaining -= pollInterval;
}
}
Chrome.java:
public void navigateTo(String url) {
if (driver == null)
return;
driver.navigate().to(url); // TimeOut
}
public void waitFor(long waitFor) {
long start = System.currentTimeMillis();
driver.manage().timeouts().implicitlyWait(waitFor, TimeUnit.MILLISECONDS);
long duration = System.currentTimeMillis() - start;
long remaining = waitFor - duration;
if (remaining > 0) {
try {
Thread.sleep(remaining);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
Error stack trace:
Connected to the target VM, address: '127.0.0.1:57086', transport: 'socket'
Starting ChromeDriver 2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b) on port 13817
Only local connections are allowed.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Vector smash protection is enabled.
Vector smash protection is enabled.
[723.497][SEVERE]: Timed out receiving message from renderer: 600.000
[1323.497][SEVERE]: Timed out receiving message from renderer: 600.000
Exception:
org.openqa.selenium.WebDriverException: unknown error: cannot
determine loading status from timeout: Timed out receiving message
from renderer: 600.000 (Session info: chrome=45.0.2454.101)
(Driver info: chromedriver=2.20.353124
(035346203162d32c80f1dce587c8154a1efa0c3b),platform=Linux
3.19.0-28-generic x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 1200.01 seconds
Build info: version: '2.48.2', revision:
'41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09
13:08:06' System info: host: 'yogesh-ubuntu', ip: '127.0.1.1',
os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-28-generic',
java.version: '1.8.0_60' Driver info:
org.openqa.selenium.chrome.ChromeDriver Capabilities
[{applicationCacheEnabled=false, rotatable=false,
mobileEmulationEnabled=false,
chrome={userDataDir=/tmp/.com.google.Chrome.rgDfCi},
takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true,
hasTouchScreen=false, version=45.0.2454.101, platform=LINUX,
browserConnectionEnabled=false, nativeEvents=true,
acceptSslCerts=true, locationContextEnabled=true,
webStorageEnabled=true, browserName=chrome, takesScreenshot=true,
javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID:
a97aeb9a53ddd77e8edfac64019cc599 at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
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.get(RemoteWebDriver.java:311)
at
org.openqa.selenium.remote.RemoteWebDriver$RemoteNavigation.to(RemoteWebDriver.java:927)
at app.core.browsers.chrome.Chrome.navigateTo(Chrome.java:112) at
app.core.extensions.tests.ShouldPostToServerTest.nav(ShouldPostToServerTest.java:58)
at
app.core.extensions.tests.ShouldPostToServerTest.setTest(ShouldPostToServerTest.java:49)
Your code runs fine. Might be you using outdated chrome driver. I suggest to use latest exe of chrome driver.
This error message...
Connected to the target VM, address: '127.0.0.1:57086', transport: 'socket'
Starting ChromeDriver 2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b) on port 13817
.
org.openqa.selenium.WebDriverException: unknown error: cannot
determine loading status from timeout: Timed out receiving message
from renderer: 600.000 (Session info: chrome=45.0.2454.101)
(Driver info: chromedriver=2.20.353124
(035346203162d32c80f1dce587c8154a1efa0c3b),platform=Linux 3.19.0-28-generic x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 1200.01 seconds
Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06' System info: host: 'yogesh-ubuntu', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-28-generic', java.version: '1.8.0_60' Driver info: org.openqa.selenium.chrome.ChromeDriver
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
Though your chromedriver=2.20 and chrome=45.0 are compatable.
But your JDK version is 1.8.0_60 which is pretty ancient.
So there is a clear mismatch between JDK v8u60 , Selenium Client v'2.48.2 , ChromeDriver v2.20 and the Chrome Browser v45.0
Solution
Ensure that:
JDK is upgraded to current levels JDK 8u241.
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v80.0 level.
Chrome is updated to current Chrome Version 80.0 level. (as per ChromeDriver v80.0 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it through and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Search using Selenium WebDriver works on google but Fails on yahoo

All:
I am running a simple Java application with Selenium WebDriver.
I was able to successfully run a search
on http://www.google.com using org.openqa.selenium.htmlunit.HtmlUnitDriver
I tried to run the same search term on http://www.yahoo.com as shown in the following code excerpt:
CharSequence[] searchTerm = { "bbc", "news" };
// Create a new instance of the html unit driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
WebDriver driver = new HtmlUnitDriver();
// And now use this to visit Google
driver.get("http://www.yahoo.com");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));
//searchTerm = "bbc news";
// Enter something to search for
element.sendKeys(searchTerm);
// Now submit the form. WebDriver will find the form for us from the element
element.submit();
// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
Howefver, it gives me the following error:
Oct 17, 2014 3:18:44 PM org.apache.http.client.protocol.ResponseProcessCookies processCookies
WARNING: Cookie rejected [DNR="deleted", version:0, domain:.www.yahoo.com, path:/, expiry:Thu Oct 17 15:18:45 IST 2013] Illegal domain attribute "www.yahoo.com". Domain of origin: "in.yahoo.com"
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element with name: q
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:58'
System info: host: , ip: , os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_05'
Driver info: driver.version: HtmlUnitDriver
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByName(HtmlUnitDriver.java:1001)
Why does it work fine for http://www.google.com but fails for http://www.yahoo.com ?
Why does it throw the "Exception in thread main org.openqa.selenium.NoSuchElementException Unable to locate element with name q" error?
Update with Answer
Thanks to #Sriram and #ivan_ochc , I am able to run the following code that searches http://www.yahoo.com properly
// Create a new instance of the html unit driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
WebDriver driver = new HtmlUnitDriver();
// And now use this to visit Google
driver.get("http://www.yahoo.com");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("p"));
http://www.yahoo.com doesn't have element with name="q", it has element with name="p"

Categories

Resources