0

I have a problem with selecting and clicking an element it so the drop down occurs here is what i have tried uptill now:-

String csspath = "html body.ng-scope f:view form#wdesk.ng-pristine.ng-valid div.container div.ng-scope md-content.md-padding._md md-tabs.ng-isolate-scope.md-dynamic-height md-tabs-content-wrapper._md md-tab-content#tab-content-7._md.ng-scope.md-active.md-no-scroll div.ng-scope.ng-isolate-scope ng-include.ng-scope div.ng-scope accordion div.accordion div.accordion-group.ng-isolate-scope div.accordion-heading a.accordion-toggle.ng-binding span.ng-scope b.ng-binding";
String uxpath = "//html//body//f:view//form//div//div[2]//md-content//md-tabs//md-tabs-content-wrapper//md-tab-content[1]//div//ng-include//div//accordion//div//div[1]//div[1]//a";
String xpath2 = "/html/body/pre/span[202]/a";
xpath = "/html/body/f:view/form/div/div[2]/md-content/md-tabs/md-tabs-content-wrapper/md-tab-content[1]/div/ng-include/div/accordion/div/div[1]/div[1]/a/span/b";
try {
  element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(csspath)));

  locator = By.cssSelector(csspath);
  driver.findElement(locator).click();
} catch (Exception e) {
  System.out.println("Not foune csspath");
}



try {
  element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath)));

  locator = By.xpath(xpath);
  driver.findElement(locator).click();
} catch (Exception e) {
  System.out.println("Not foune xpath");
}

try {
  element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(uxpath)));

  locator = By.xpath(uxpath);
  driver.findElement(locator).click();
} catch (Exception e) {
  System.out.println("Not foune uxpath");
}

try {
  element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath2)));

  locator = By.xpath(xpath2);
  driver.findElement(locator).click();
} catch (Exception e) {
  System.out.println("Not foune xpath2");
}

However nothing has worked till now i want to select responsibility code and give it values

It would be really appreciated if you can give me any insight Thanks in advance Here is a screenshot of my issue enter image description here

1 Answers1

0

First issue (as already pointed out in comments) is the absolute selectors you are using. For example, try to refactor your xpath selectors and make those relative.

Next issue is related to the

AngularJs page

itself. Let's look at Protractor, the testing framework for Angular built upon WebDriverJS, it provides additional WebDriver-like functionality to test Angular based websites. Put simple - your code needs extra functionality that will know when Angular elements are available for interaction.

Here is how to port some of the most useful Protractor functions to Java (and Python):

enter image description here

Community
  • 1
  • 1
ekostadinov
  • 6,880
  • 3
  • 29
  • 47