1

I have the following URL that I need to get the 4805206 code from.

 href="http://adserver.adtech.de/adlink|832|4805206|0|1686|AdId=9624985;BnId=1;itime=527032581;nodecode=yes;link=http://URL/Recruiters/Lex-Consultancy-3979.aspx"

I was wondering if its possible to do this and if so how?

Heres my Java Selenium Class

    public void checkAdTechKeys(WebDriver driver) {

    if(driver.getCurrentUrl().equalsIgnoreCase("URL"))
    {
        HP_LeftSearchBox(driver);//enter search terms
        driver.get("URL");
        // driver.findElement(By.linkText("Read     More")).getAttribute("href").toString();
                    String url = new String(driver.findElement(By.linkText("Read More")).getAttribute("href").toString());
                //  url = url.split("|")[2];
                 System.out.println(url);
    }else{
        setup.loadHomePage(driver);
        checkAdTechKeys(driver);
    } 
}

1 Answer 1

4

The code with a small modification that prints out that number:

driver.get("http://irishjobs.ie/");
String url = driver.findElement(By.linkText("Read More")).getAttribute("href");
String[] parsedUrl = url.split("\\|");
System.out.println(parsedUrl[2]);

Two things that you missed:

  • escaping the "|"
  • .split() returns an array of strings, not a string.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.