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
Related
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.
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);
I am having an issue with Selenium targeting a username and password textbox. My main goal is to have my program open Chrome browser, load isis.ufl.edu, proceed to registration, then sign on with the user's username and password. The problem is that when I give an xpath or css path to target the username and password textbox, Eclipse gives me a error stating it cant find the element. Some say this only occurs with Chrome but does anyone know a way around this?
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element
(Session info: chrome=40.0.2214.115)
(Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Mac OS X 10.10.2 x86_64) (WARNING: The server did not provide any stacktrace information)
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.44.0', revision: '76d78cf', time: '2014-10-23 20:03:00'
System info: host: 'Dailens-MacBook-Pro.local', ip: '192.168.1.102', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.2', java.version: '1.7.0_67'
Session ID: c8b9c346dcf7bcdc28c1cc078638d872
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/var/folders/81/v5g4vbfj05x16pgjg9h7_kf40000gn/T/.org.chromium.Chromium.ML2rMj}, rotatable=false, locationContextEnabled=true, mobileEmulationEnabled=false, version=40.0.2214.115, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, applicationCacheEnabled=false, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:352)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:441)
at org.openqa.selenium.By$ByCssSelector.findElement(By.java:426)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:344)
at TestClass.main(TestClass.java:51)
Here is my code :
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.util.Scanner;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
public class TestClass {
public static void main(String[] args) {
//Fetching isis and schedule information
Scanner user_input = new Scanner(System.in);
System.out.println("User enter Isis username:");
System.out.println("User enter Isis password:");
System.out.println("User enter current semester:");
String username = user_input.next();
String password = user_input.next();
String semester = user_input.next();
// Create a new instance of the chrome driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
System.setProperty("webdriver.chrome.driver", "//users/dailenspencer/downloads/chromedriver");
WebDriver driver = new ChromeDriver();
// And now use this to visit isis
driver.get("http://www.isis.ufl.edu/");
// Alternatively the same thing can be done like this
// driver.navigate().to("http://www.isis.ufl.edu/");
//Clicking on registration tab
driver.findElement(By.xpath("//a[#class='hideToggle2']")).click();
//If user input fall for semester, click on fall registration
if(semester.charAt(0) == 'f' || semester.charAt(0) == 'F'){
driver.findElement(By.cssSelector("#reg > ul:nth-child(3) > li:nth-child(3) > a")).click();
}
//If user input summer, click on summer registration tab
if(semester.charAt(1) == 'u'){
driver.findElement(By.cssSelector("#reg > ul:nth-child(3) > li:nth-child(2) > a")).click();
}
//else, click spring registration tab
else{
driver.findElement(By.cssSelector("#reg > ul:nth-child(3) > li:nth-child(1) > a")).click();
}
long end = System.currentTimeMillis() + 5000;
while (System.currentTimeMillis() < end) {
WebElement resultsDiv = driver.findElement(By.className("wrap"));
// If results have been returned, the results are displayed in a drop down.
if (resultsDiv.isDisplayed()) {
break;
}
}
//Find the textbox for username, and send username to text box
WebElement elementu = driver.findElement(By.cssSelector("#username"));
elementu.sendKeys(username);
WebElement elementp = driver.findElement(By.cssSelector("#password"));
elementp.sendKeys(password);
// Now submit the form. WebDriver will find the form for us from the element
driver.findElement(By.cssSelector("body > div.content > div > form > p:nth-child(3) > input")).click();
// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());
// Google's search is rendered dynamically with JavaScript.
// Wait for the page to load, timeout after 10 seconds
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("isis");
}
});
//Close the browser
driver.quit();
}
}
You need to explicitly wait for elements to become visible before interacting with them, example for the "Transcripts" link:
WebDriverWait wait = new WebDriverWait(webDriver, 5);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[#class='hideToggle2']")));
Also, it looks like it is failing while trying to find the Summer registration link. I'd find it by partial link text instead of diving into CSS selectors:
driver.findElement(By.partialLinkText("Summer")).click();
I am trying to crawl and parse a dynamic content of website using selenium,
Generally the website am crawling loads its content by the scroll event from the page,So i triggered the scroll event by selenium until the end of the page is reached.
In Product phase am fetching each product detail by loop iteration, it also works fine.. but when it reaches iteration count of 280 above....
This is my code below...
private void init() throws IOException {
FirefoxProfile profile = new FirefoxProfile();//Create Firefox profile
profile.setPreference("javascript.enabled", true);//Allow javascript for browser
WebDriver htmDriver = new FirefoxDriver(profile);//add profile to firefoxDriver
htmDriver.get(urlTextField.getText());//Get and Connect to the url from URL text Field
htmDriver.manage().window().maximize();//Maximize the Browser window
String count = htmDriver.findElement(By.cssSelector("#numbFound > #no-of-results-filter")).getText();//Total Product Count for the category
//System.out.println("Total Category Count : "+count);
htmDriver.findElement(By.cssSelector(".list")).click();//Click to view the Product in List
htmDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);//Wait
int lCount = Integer.parseInt(count);//Calculate the scroll length
for (int i = 1; i <= Math.ceil(lCount / 5); i++) {
//Generate Arrow Down Action
htmDriver.findElement(By.id("products-main4")).sendKeys(
Keys.ARROW_DOWN);
htmDriver.findElement(By.id("products-main4")).sendKeys(
Keys.ARROW_DOWN);
htmDriver.findElement(By.id("products-main4")).sendKeys(
Keys.ARROW_DOWN);
htmDriver.findElement(By.id("products-main4")).sendKeys(
((JavascriptExecutor) htmDriver).executeScript(
"window.scrollBy(0,document.body.scrollHeight)", "");
htmDriver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}
//Product Phase
int row2 = 0;
List<WebElement> rdata = htmDriver.findElements(By.className("product_list_view_cont"));//selector to select each product row
for (WebElement data : rdata) {
String title = data.findElement(By.cssSelector(".product_list_view_heading")).getText();//Get Product Title
System.out.println(title);
//Check if Product Price available
boolean product_price = data.findElements(By.cssSelector(".product_list_view_price_outer span")).isEmpty();
if(product_price == false){
//Get the Price of the Product
String price = data.findElement(By.cssSelector(".product_list_view_price_outer var[id^=selling-price-id-]")).getText().trim();
System.out.println(price);
}else{
//If Price not Available add make the data null
system.out.println("No price")
}
String brand = data.findElement(By.cssSelector("ul.key-features li")).getText();
System.out.println(brand);
String brandUrl = data.findElement(By.cssSelector(".product_list_view_info_cont a")).getAttribute("href");//Fetch Brand Url
System.out.println(brandUrl);
String status = data.findElement(By.cssSelector(".product_list_view_buy-outer .lfloat")).getText();//Fetch Brand Url
System.out.println(status);
}
}
selenium throws exception as follows
Feb 18, 2015 10:00:10 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.BindException) caught when processing request to {}->http://localhost:7055: Address already in use: connect
Feb 18, 2015 10:00:10 AM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->http://localhost:7055
Feb 18, 2015 10:00:10 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.BindException) caught when processing request to {}->http://localhost:7055: Address already in use: connect
Feb 18, 2015 10:00:10 AM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->http://localhost:7055
Feb 18, 2015 10:00:10 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.BindException) caught when processing request to {}->http://localhost:7055: Address already in use: connect
Feb 18, 2015 10:00:10 AM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->http://localhost:7055
Feb 18, 2015 10:00:12 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.BindException) caught when processing request to {}->http://localhost:7055: Address already in use: connect
Feb 18, 2015 10:00:12 AM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->http://localhost:7055
Feb 18, 2015 10:00:12 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.BindException) caught when processing request to {}->http://localhost:7055: Address already in use: connect
Feb 18, 2015 10:00:12 AM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->http://localhost:7055
Feb 18, 2015 10:00:12 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.BindException) caught when processing request to {}->http://localhost:7055: Address already in use: connect
Feb 18, 2015 10:00:12 AM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->http://localhost:7055
for each Iteration after some times...
Does anyone know how to do the TURN portion of Ice4j? I've managed to code it so that it works when the phone is on WiFi, but not when its on the mobile network.
I'm sending agent info via TCP and then building the connection manually instead of using a signalling process. The TCP connection already works fine, so I don't think its the TCP issue. Maybe I'm building the agent wrong?
I know that you're supposed to use a TURN server if STUN doesn't work, and I provided a large list of public TURN servers, but I might be missing something. Maybe the packets aren't being sent out properly?
Error: (Mostly Failed to send ALLOCATE-REQUEST(0X3))
Sep 11, 2014 3:36:09 PM org.ice4j.ice.Agent createMediaStream
INFO: Create media stream for data
Sep 11, 2014 3:36:09 PM org.ice4j.ice.Agent createComponent
INFO: Create component data.1
Sep 11, 2014 3:36:09 PM org.ice4j.ice.Agent gatherCandidates
INFO: Gather candidates for component data.1
Sep 11, 2014 3:36:09 PM org.ice4j.ice.harvest.HostCandidateHarvester harvest
INFO: End candidate harvest within 160 ms, for org.ice4j.ice.harvest.HostCandidateHarvester, component: 1
Sep 11, 2014 3:36:09 PM org.ice4j.ice.harvest.StunCandidateHarvest sendRequest
INFO: Failed to send ALLOCATE-REQUEST(0x3)[attrib.count=3 len=32 tranID=0x9909DC6648016A67FDD4B2D8] through /192.168.0.8:5001/udp to stun2.l.google.com:19302:5001/udp
Sep 11, 2014 3:36:12 PM org.ice4j.ice.ConnectivityCheckClient processTimeout
INFO: timeout for pair: /fe80:0:0:0:c8ce:5a17:c339:cc40%4:5001/udp -> /fe80:0:0:0:14e8:f3ff:fef3:6a21:6001/udp (data.1), failing.
Sep 11, 2014 3:36:12 PM org.ice4j.ice.ConnectivityCheckClient processTimeout
INFO: timeout for pair: /fe80:0:0:0:380d:2a4c:b350:eea8%8:5001/udp -> /fe80:0:0:0:14e8:f3ff:fef3:6a21:6001/udp (data.1), failing.
Sep 11, 2014 3:36:12 PM org.ice4j.ice.ConnectivityCheckClient processTimeout
INFO: timeout for pair: /192.168.0.8:5001/udp -> /100.64.74.58:6001/udp (data.1), failing.
Sep 11, 2014 3:36:12 PM org.ice4j.ice.ConnectivityCheckClient processTimeout
INFO: timeout for pair: /192.168.0.8:5001/udp -> /100.64.74.58:6001/udp (data.1), failing.
Sep 11, 2014 3:36:12 PM org.ice4j.ice.ConnectivityCheckClient updateCheckListAndTimerStates
INFO: CheckList will failed in a few seconds if nosucceeded checks come
Sep 11, 2014 3:36:17 PM org.ice4j.ice.ConnectivityCheckClient$1 run
INFO: CheckList for stream data FAILED
Sep 11, 2014 3:36:17 PM org.ice4j.ice.Agent checkListStatesUpdated
INFO: ICE state is FAILED
Script (Both the server and the client sides have similar codes to this one):
Agent agent = new Agent();
agent.setControlling(false);
StunCandidateHarvester stunHarv = new StunCandidateHarvester(new TransportAddress("sip-communicator.net", port, Transport.UDP));
StunCandidateHarvester stun6Harv = new StunCandidateHarvester(new TransportAddress("ipv6.sip-communicator.net", port, Transport.UDP));
agent.addCandidateHarvester(stunHarv);
agent.addCandidateHarvester(stun6Harv);
String[] hostnames = new String[] { "130.79.90.150",
"2001:660:4701:1001:230:5ff:fe1a:805f",
"jitsi.org",
"numb.viagenie.ca",
"stun01.sipphone.com",
"stun.ekiga.net",
"stun.fwdnet.net",
"stun.ideasip.com",
"stun.iptel.org",
"stun.rixtelecom.se",
"stun.schlund.de",
"stun.l.google.com:19302",
"stun1.l.google.com:19302",
"stun2.l.google.com:19302",
"stun3.l.google.com:19302",
"stun4.l.google.com:19302",
"stunserver.org",
"stun.softjoys.com",
"stun.voiparound.com",
"stun.voipbuster.com",
"stun.voipstunt.com",
"stun.voxgratia.org",
"stun.xten.com",};
LongTermCredential longTermCredential = new LongTermCredential("guest", "anon");
for (String hostname : hostnames)
agent.addCandidateHarvester(new TurnCandidateHarvester(new TransportAddress(hostname, port, Transport.UDP), longTermCredential));
//Build a stream for agent
IceMediaStream stream = agent.createMediaStream("data");
try {
Component c = agent.createComponent(stream, Transport.UDP, port, port, port+100 );
String response = "";
List<LocalCandidate> remoteCandidates = c.getLocalCandidates();
for(Candidate<?> can : remoteCandidates) {
response += "||" + can.toString();
}
response = "Video||" + agent.getLocalUfrag() + "||" + agent.getLocalPassword() + "||" + c.getDefaultCandidate().toString() + response;
System.out.println("Server >>> " + response);
DataOutputStream outStream = new DataOutputStream(client.getOutputStream());
outStream.write(response.getBytes("UTF-8"));
outStream.flush();
List<IceMediaStream> streams = agent.getStreams();
for(IceMediaStream localStream : streams) {
List<Component> localComponents = localStream.getComponents();
for(Component localComponent : localComponents) {
for(int i = 3; i < info.length; i++) {
String[] detail = info[i].split(" "); //0: Foundation
//1: Component ID
//2: Transport
//3: Priority #
//4: Address (Needed with Port # to create Transport Address)
//5: Port # (Needed with Address to create Transport Address)
//6: -filler: "Type" is next field-
//7: Candidate Type
String[] foundation = detail[0].split(":"); //Turn "Candidate:#" -> "Candidate" and "#". We use "#"
localComponent.addRemoteCandidate(new RemoteCandidate(new TransportAddress(detail[4], Integer.valueOf(detail[5]), Transport.UDP), c, CandidateType.HOST_CANDIDATE, foundation[1], Long.valueOf(detail[3]), null));
}
String[] defaultDetail = info[3].split(" ");
String[] defaultFoundation = defaultDetail[0].split(":");
localComponent.setDefaultRemoteCandidate(new RemoteCandidate(new TransportAddress(defaultDetail[4], Integer.valueOf(defaultDetail[5]), Transport.UDP), c, CandidateType.HOST_CANDIDATE, defaultFoundation[1], Long.valueOf(defaultDetail[3]), null));
}
localStream.setRemoteUfrag(info[1]);
localStream.setRemotePassword(info[2]);
}
agent.startConnectivityEstablishment();
System.out.println("ICEServer <><><> Completed");
I realize now that your list of TURN servers seem to mostly actually be STUN servers (not sure about the first two). They should be added as STUN servers if anything:
agent.addCandidateHarvester(
new StunCandidateHarvester(
new TransportAddress(
InetAddress.getByName('stun.l.google.com'),
19302,
Transport.UDP)));