This question already has an answer here:
How to set proxy authentication in PhantomJS using selenium?
(1 answer)
Closed 6 years ago.
I just added the two lines related about proxy
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability("takesScreenshot", true);
caps.setCapability("screen-resolution", "1280x1024");
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "C:\\Users\\USERNAME\\Downloads\\phantomjs-2.0.0-windows\\bin\\phantomjs.exe");
caps.setCapability("proxy", "127.0.0.1:1024"); //added this line
caps.setCapability("proxy-type", "socks"); //and this line
Logger.getLogger(PhantomJSDriverService.class.getName()).setLevel(Level.OFF);
driver = new PhantomJSDriver(caps);
But now I get the following error when I run the program
[INFO - 2015-08-04T00:34:45.924Z] GhostDriver - Main - running on port 15821
[ERROR - 2015-08-04T00:34:46.845Z] RouterReqHand - _handle.error - {"stack":"\tat _getProxySettingsFromCapabilities (:/ghostdriver/session.js:131:41)\n\tat Session (:/ghostdriver/session.js:165:62)\n\tat _postNewSessionCommand (:/ghostdriver/request_handlers/session_manager_request_handler.js:75:49)\n\tat _handle (:/ghostdriver/request_handlers/session_manager_request_handler.js:44:35)\n\tat _handle (:/ghostdriver/request_handlers/router_request_handler.js:70:37)","line":131,"sourceURL":":/ghostdriver/session.js"}
:262 in error
[INFO - 2015-08-04T00:34:46.861Z] ShutdownReqHand - _handle - About to shutdown
Aug 03, 2015 8:34:47 PM org.openqa.selenium.os.UnixProcess$SeleniumWatchDog destroyHarder
INFO: Command failed to close cleanly. Destroying forcefully (v2). org.openqa.selenium.os.UnixProcess$SeleniumWatchDog#7e1d83ab
org.openqa.selenium.UnsupportedCommandException: TypeError - undefined is not an object (evaluating 'proxyCapability["proxyType"].toLowerCase')
What I am doing wrong?
I have figured it out, here is how it's for whoever that runs into the same question
ArrayList<String> cliArgsCap = new ArrayList<String>();
cliArgsCap.add("--proxy=127.0.0.1:1024");
// cliArgsCap.add("--proxy-auth=username:password");
cliArgsCap.add("--proxy-type=socks5");
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability("takesScreenshot", true);
caps.setCapability("screen-resolution", "1280x1024");
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "C:\\Users\\USER\\Downloads\\phantomjs-2.0.0-windows\\bin\\phantomjs.exe");
caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);
Logger.getLogger(PhantomJSDriverService.class.getName()).setLevel(Level.OFF);
driver = new PhantomJSDriver(caps);
Related
Given:
from selenium import webdriver
import os
def setUp_Browser():
if 'nt' in os.name.lower():
# import psutil
# for proc in psutil.process_iter():
# if proc.name() == "chromedriver.exe":
# proc.kill()
time.sleep(1)
caps = webdriver.DesiredCapabilities.CHROME.copy()
caps['goog:loggingPrefs'] = {'performance': 'ALL'}
options = webdriver.ChromeOptions()
options.add_argument("--start-maximized")
options.add_argument('ignore-certificate-errors')
options.add_argument("--incognito")
caps['acceptInsecureCerts'] = True
import pathlib
projectDir = str(pathlib.Path(__file__).parent.absolute()) + "\\Resources\\Drivers\\"
executable_path = os.path.join(projectDir, "chromedriver.exe")
self.browser = webdriver.Chrome(executable_path=executable_path, options=options, desired_capabilities=caps)
time.sleep(3)
self.browser.get(url='www.google.ro')
self.browser.implicitly_wait(15)
time.sleep(4)
I cannot access any given url, it always raises an invalid arg exception after the latest driver update:
File "C:\Users\MunteanuG\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:\Users\MunteanuG\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\MunteanuG\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument
(Session info: chrome=91.0.4472.101)
Some more text so i can post the question...........
Adding http or https, and removing "www." from the url seems to work fime
have problems with my java tests on Cucumber when i run them via jenkins on remote host.
My code:
step:
Given open link from property "bla-blalink"
And type to input with name "UserName" property: "login" on "LoginPage"
element:
#NameOfElement("UserName")
#FindBy(id = "UserName")
public SelenideElement username;
step def:
#And("^type to input with name \"([^\"]*)\" property: \"([^\"]*)\" on \"([^\"]*)\"$")
public void typeToInputWithNamePropertyOn(String nameOfElement, String property, String page) throws InterruptedException, IOException {
sleep(5000);
Properties properties = new Properties();
try (FileReader fileReader = new FileReader(Constants.PROPERTY_PATH)) {
properties.load(fileReader);
}
if ("LoginPage".equals(page)) {
loginPage.get(nameOfElement).sendKeys(properties.getProperty(property));
} else if ("MainPage".equals(page)) {
mainPage.get(nameOfElement).sendKeys(properties.getProperty(property));
} else if ("ActionPage".equals(page)) {
actionPage.get(nameOfElement).sendKeys(properties.getProperty(property));
}
}
configure:
#BeforeClass
static public void setupTimeout() {
/////////////////////////////////for remote runs////////////////////////////////
// Configuration.remote = "http://10.52.185.105:4419/wd/hub";
// Configuration.browser = "chrome";
// DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setBrowserName("chrome");
// capabilities.setCapability(ACCEPT_SSL_CERTS, true);
// WebDriver wd = new RemoteWebDriver(new URL("http://10.52.185.105:4419/wd/hub"), capabilities);
// setWebDriver(wd);
///////////////////////////////////for local runs////////////////////////////
Configuration.timeout = 10000;
System.setProperty("webdriver.chrome.driver", "src/main/resources/webdrivers/chromedriver.exe");
Configuration.browser = "chrome";
What i tried:
it works locally
it works on remote machine(without jenkins)
change window size - doesnt help
change sleep on 35000ms - doesnt help
our jenkins
not started as a service, so i dont know how to allow to interact with elements
output:
T E S T S
Running ru.open.runners.BusinessPortalTest
июн 13, 2018 9:55:27 AM com.codeborne.selenide.impl.WebDriverThreadLocalContainer getWebDriver
INFO: No webdriver is bound to current thread: 1 - let's create new webdriver
Starting ChromeDriver 2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb) on port 5610
Only local connections are allowed.
июн 13, 2018 9:55:31 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
июн 13, 2018 9:55:33 AM com.codeborne.selenide.webdriver.WebDriverFactory logBrowserVersion
INFO: BrowserName=chrome Version=67.0.3396.87 Platform=XP
июн 13, 2018 9:55:33 AM com.codeborne.selenide.webdriver.WebDriverFactory createWebDriver
INFO: Selenide v. 4.11.4
июн 13, 2018 9:55:33 AM com.codeborne.selenide.webdriver.WebDriverFactory logSeleniumInfo
INFO: Selenium WebDriver v. 3.12.0 build time: 2018-05-08T14:04:26.12Z
июн 13, 2018 9:55:33 AM com.codeborne.selenide.impl.WebDriverThreadLocalContainer createDriver
INFO: Create webdriver in current thread 1: ChromeDriver -> ChromeDriver: chrome on XP (9879008c2825cc8b84a452e24010d66d)
Failed scenarios:
businessportaltest.feature:440 # Scenario: Change phone number
157222(verify ONLY with payment order)
1 Scenarios (1 failed)
29 Steps (1 failed, 27 skipped, 1 passed)
0m18.951s
java.lang.IllegalArgumentException: ERROR: there is no such element with name Имя пользователя at page ru.open.pageobjects.businessportal.LoginPage
at ru.open.pageobjects.AbstractPage.get(AbstractPage.java:27)
at ru.open.steps.MyStepdefs.typeToInputWithNamePropertyOn(MyStepdefs.java:63)
at ?.And type to input with name "Имя пользователя" property: "login" on "LoginPage"(businessportaltest.feature:443)
remote machine - windows server 2012R
The following code opens an internet explorer, goes to the website youtube.com, opens a video, searches for a webelement (with id movie_player), hovers over the mouse to go to the center of webelement (ie: middle of youtube video screen so that the duration tab is visible), then tries to fetch the value of total duration and duration elapsed.
The problem seems to be that its not able to find the web element for current time as it seems the mouse hovering action does not happen as expected.
How to achieve the mouse hovering correctly?
WebDriver driver4 = new InternetExplorerDriver();
driver4.get("https://www.youtube.com");
String[] arr = {"saiyoni saiyoni song video","bulla ki jaana main kaun video song"};
WebDriverWait wait7 = new WebDriverWait(driver4,30);
WebElement textBox2 = wait7.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[id=masthead-search-term]")));
textBox2.sendKeys(arr[0]);
wait7.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//button[#id='search-btn']"))).click();
WebElement we0 = wait7.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[#href='/watch?v=0GLYKYgSE0Y']")));
we0.click();
Actions builder = new Actions(driver4);
WebElement we = driver4.findElement(By.id("movie_player"));
Action mouseMovement=builder.moveToElement(we).build();
mouseMovement.perform();
WebElement currentTime = wait9.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[#class='ytp-time-current']")));
WebElement durationTime= wait9.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[#class='ytp-time-duration']")));
Error:
Exception in thread "main" org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.xpath: //span[#class='ytp-time-duration'] (tried for 30 second(s) with 500 MILLISECONDS interval)
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:26.402Z'
System info: host: 'ADMIN-PC', ip: '192.168.1.5', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_151'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{acceptInsecureCerts=false, browserVersion=11, se:ieOptions={nativeEvents=true, browserAttachTimeout=0, ie.ensureCleanSession=false, elementScrollBehavior=0, enablePersistentHover=true, ie.browserCommandLineSwitches=, ie.forceCreateProcessApi=false, requireWindowFocus=false, initialBrowserUrl=http://localhost:5514/, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, ignoreProtectedModeSettings=false}, browserName=internet explorer, pageLoadStrategy=normal, javascriptEnabled=true, platformName=WINDOWS, setWindowRect=true, platform=WINDOWS}]
Session ID: 84b0b0b5-af27-4208-82bb-599d9ffa2552
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:82)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:231)
at packageFF.browserAutomation.main(browserAutomation.java:116)
WebDriver driver=new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("https://www.wonderplugin.com/wordpress-lightbox");
WebElement element=driver.findElement(By.xpath("//a[contains(text(),'Open a Div in Lightbox')]"));
element.click();
System.out.println("found element and clicked");
Thread.sleep(3000);
WebElement frameElement=driver.findElement(By.xpath("//iframe[#src='https://www.youtube.com/embed/wswxQ3mhwqQ']"));
driver.switchTo().frame(frameElement);
driver.findElement(By.xpath("//button[#aria-label=\'Play\']")).click();
Actions builder = new Actions(driver);
WebElement we = driver.findElement(By.className("ytp-progress-bar-container"));
Action mouseMovement=builder.moveToElement(we).build();
mouseMovement.perform();
we.click();
WebDriverWait wait = new WebDriverWait(driver, 20);
WebElement titleText=wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("ytp-title-link")));
System.out.println(titleText.getText());
WebElement time=wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("span.ytp-time-current")));
System.out.println(time.getText());
I am not able to select value from drop down for day, month and year while doing the registration on boohoo ecommerce site due to which I am not able to do further actions.
could you please help me to resolve this issue
site:http://www.boohoo.com/
steps1 :open URL of Boohoo,
Step 2: Go to User Icon then click on registeration link
==============================================
public class Boohoo {
WebDriver driver;
#BeforeMethod
public void beforeMethod() {
System.setProperty("webdriver.chrome.driver","C:\\Chrome\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("credentials_enable_service", false);
prefs.put("password_manager_enabled", false);
options.setExperimentalOption("prefs", prefs);
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
driver = new ChromeDriver(options);
}
#Test(priority=3)
public void BoohooURLverify() {
driver.get("http://www.boohoo.com/");
String Title=driver.getTitle();
if(Title.endsWith("http://www.boohoo.com/"))
{
System.out.println("Url is verifedand is correct");
}
else
System.out.println("Incorrect URl is opened");
driver.quit();
}
#Test(priority=1)
public void BohooRegisteration() {
driver.get("http://www.boohoo.com/");
Actions Action=new Actions(driver);
WebElement User_link=driver.findElement(By.xpath(".//*[#id='wrapper']/div[4]/div[1]/div/ul/li[2]/div/span"));
WebElement Register_link=driver.findElement(By.xpath(".//*[#id='wrapper']/div[4]/div[1]/div/ul/li[2]/div/div/div/a[2]"));
Action.moveToElement(User_link).moveToElement(Register_link).click().build().perform();
WebElement Register_page_title=driver.findElement(By.xpath(".//*[#id='main']/div/h1")) ;
String Register_page_Title=Register_page_title.getText();
System.out.println(Register_page_Title);
if (Register_page_Title=="Create Account")
{
System.out.println("Page Title is correct");
}
else
{
System.out.println("Incorrect title of registration page");
}
Select drpdwn1=new Select(driver.findElement(By.xpath(".//*[#id='dwfrm_profile_customer_title']")));
drpdwn1.selectByVisibleText("Miss");
driver.findElement(By.xpath(".//*[#id='dwfrm_profile_customer_firstname']")).sendKeys("Rashmi");
driver.findElement(By.xpath(".//*[#id='dwfrm_profile_customer_lastname']")).sendKeys("Patil");
Select drpdwn2=new Select(driver.findElement(By.xpath(".//*[#id='dwfrm_profile_customer_dayofbirth']")));
drpdwn1.selectByVisibleText("05");
drpdwn1.selectByIndex(02);
Select drpdwn3=new Select(driver.findElement(By.xpath(".//*[#id='dwfrm_profile_customer_monthofbirth']")));
drpdwn1.selectByVisibleText("05");
Select drpdwn4=new Select(driver.findElement(By.xpath(".//*[#id='dwfrm_profile_customer_yearofbirth']")));
drpdwn1.selectByVisibleText("1990");
Select drpdwn5=new Select(driver.findElement(By.xpath(".//*[#id='dwfrm_profile_customer_gender']")));
drpdwn1.selectByVisibleText("Female");
driver.findElement(By.id("dwfrm_profile_customer_email")).sendKeys("vaishali.1990#rediffmail.com");
driver.findElement(By.id("dwfrm_profile_customer_emailconfirm")).sendKeys("vaishali.1990#rediffmail.com");
driver.findElement(By.id("dwfrm_profile_login_password_d0dazcxwlbzi")).sendKeys("vaishali.1990#rediffmail.com");
driver.findElement(By.id("dwfrm_profile_login_passwordconfirm_d0ehbfaagjuv")).sendKeys("vaishali.1990#rediffmail.com");
driver.findElement(By.xpath(".//*[#id='RegistrationForm']/fieldset[2]/div[9]/button")).click();
System.out.println("Account should be created sucessfully");
driver.close();
}
}
==============================================
Error message: Below it's the error
org.openqa.selenium.NoSuchElementException: Cannot locate element with text: 05
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'D90ZC6Q1', ip: '192.168.163.235', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_92'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.Select.selectByVisibleText(Select.java:150)
at ecommerce_pack1.Boohoo.BohooRegisteration(Boohoo.java:82)
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:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
===============================================
Default test
Tests run: 2, Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 2, Failures: 1, Skips: 0
===============================================
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter#1b40d5f0: 243 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter#35851384: 56 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter#1ae369b7: 46 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 65 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2#d7b1517: 8 ms
[TestNG] Time taken by org.testng.reporters.jq.Main#2b80d80f: 111 ms
Here is the Answer to your Question:
Once you open the url https://www.boohoo.com and browse to the https://www.boohoo.com/register page, the following code block will select Day as 05, Month as 05 and Year as 1990:
WebElement day_dropdown = driver.findElement(By.id("dwfrm_profile_customer_dayofbirth"));
Select day = new Select(day_dropdown);
day.selectByVisibleText("05");
WebElement month_dropdown = driver.findElement(By.id("dwfrm_profile_customer_monthofbirth"));
Select month = new Select(month_dropdown);
month.selectByVisibleText("05");
WebElement year_dropdown = driver.findElement(By.id("dwfrm_profile_customer_yearofbirth"));
Select year = new Select(year_dropdown);
year.selectByVisibleText("1990");
Let me know if this Answers your Question.
You have made few mistakes in your program. You have used the incorrect dropdown for sending values.
Lines of your code
Select drpdwn2=new Select(driver.findElement(By.xpath(".//*[#id='dwfrm_profile_customer_dayofbirth']")));
drpdwn1.selectByVisibleText("05");
drpdwn1.selectByIndex(02);
Modified Code
Select drpdwn2=new Select(driver.findElement(By.xpath(".//*[#id='dwfrm_profile_customer_dayofbirth']")));
drpdwn2.selectByVisibleText("05");
If none of the select approaches work, you can click the dropdown arrow to open it and then click By.linkText("05"). Is not as elegant solution as the other ones, but should do the work.
I am currently trying to re-run an old Selenium test. It was working as intended previously but now when I try to run it, I get an error. Here is the following code:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class IMDBSearch {
public static void main(String[] args)
{
//new driver for chrome
WebDriver driver = new ChromeDriver();
//entering the url
String url = "http://www.imdb.com/search/title";
driver.get(url);
//clicking the featured film radio button
WebElement featureFilm = driver.findElement(By.id("title_type-1"));
featureFilm.click();
//clicking the tvmovie radio button
WebElement tvMovie = driver.findElement(By.id("title_type-2"));
tvMovie.click();
//clicking the tv radio button
WebElement tvButton = driver.findElement(By.id("title_type-3"));
tvButton.click();
//using the xpath to select a 7.0 minimum rating
WebElement userRating = driver.findElement(By.xpath("//body//div[#id='main']//div/select[#name='user_rating-min']/option[text()= '7.0']"));
userRating.click();
//using xpath to select US as a country
WebElement country = driver.findElement(By.xpath("//body//div[#id='main']//div/select[#class = 'countries']/option[#value= 'us']"));
country.click();
//using xpath to select the sorting by user rating
WebElement sort = driver.findElement(By.xpath("//body//div[#id= 'main']//div/select[#name = 'sort']/option[#value = 'user_rating,asc']"));
sort.click();
//using xpath to click on the search button
WebElement searchButton = driver.findElement(By.xpath("//div[#id= 'main']/p/button[text()= 'Search']"));
searchButton.click();
//using xpath to get the first movie from the list
//displaying the first movie from the list
WebElement firstTitle = driver.findElement(By.xpath("//div[#id = 'main']//h3/span[text()= '1.']/following-sibling::a"));
String title = firstTitle.getText();
System.out.println("1. " + title);
//using xpath to get the second movie from the list
//displaying the second movie from the list
WebElement secondTitle = driver.findElement(By.xpath("//div[#id = 'main']//h3/span[text()= '2.']/following-sibling::a"));
String title2 = secondTitle.getText();
System.out.println("2. " + title2);
//using xpath to get the third movie from the list
//displaying the third movie from the list
WebElement thirdTitle = driver.findElement(By.xpath("//div[#id = 'main']//h3/span[text()= '3.']/following-sibling::a"));
String title3 = thirdTitle.getText();
System.out.println("3. " + title3);
//using xpath to get the fourth movie from the list
//displaying the fourth movie from the list
WebElement fourthTitle = driver.findElement(By.xpath("//div[#id = 'main']//h3/span[text()= '4.']/following-sibling::a"));
String title4 = fourthTitle.getText();
System.out.println("4. " + title4);
//using xpath to get the fifth movie from the list
//displaying the fifth movie from the list
WebElement fifthTitle = driver.findElement(By.xpath("//div[#id = 'main']//h3/span[text()= '5.']/following-sibling::a"));
String title5 = fifthTitle.getText();
System.out.println("5. " + title5);
}
While I know this was working previously, it has been shooting me this error:
Starting ChromeDriver 2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129) on port 20969
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData": {"frameId":"3940.1","isDefault":true},"id":1,"name":"","origin":"://"}
(Session info: chrome=55.0.2883.87)
(Driver info: chromedriver=2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.14 seconds
Build info: version: '3.0.0-beta2', revision: '2aa21c1', time: '2016-08-02 15:03:28 -0700'
System info: host: 'Qualitest-PC', ip: '192.168.2.106', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
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:683)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:143)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
at PracticeClass.main(PracticeClass.java:10)
You should try updating your chromedriver version. The version you are using (v2.23) is only specified for v51-53 and you are using Chrome 55. Try with the latest chromedriver v2.27