Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Toolkit;
- import java.awt.datatransfer.Clipboard;
- import java.awt.datatransfer.StringSelection;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.concurrent.TimeUnit;
- import org.apache.poi.EncryptedDocumentException;
- import org.apache.poi.ss.usermodel.Cell;
- import org.apache.poi.ss.usermodel.Row;
- import org.apache.poi.ss.usermodel.Sheet;
- import org.apache.poi.ss.usermodel.Workbook;
- import org.apache.poi.ss.usermodel.WorkbookFactory;
- import org.jsoup.Jsoup;
- import org.junit.Assert;
- import org.openqa.selenium.By;
- import org.openqa.selenium.JavascriptExecutor;
- import org.openqa.selenium.Keys;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.chrome.ChromeDriver;
- import org.openqa.selenium.support.ui.ExpectedConditions;
- import org.openqa.selenium.support.ui.Select;
- import org.openqa.selenium.support.ui.WebDriverWait;
- public class scopus {
- public static void main(String[] args) throws EncryptedDocumentException, FileNotFoundException, IOException, InterruptedException {
- // TODO Auto-generated method stub
- List<String> ISSN_List = new ArrayList<>();
- String saved_issn="";
- String enter_email = "30049683@westernsydney.edu.au";
- File file = new File("Selenium.xlsx");
- Workbook wb = WorkbookFactory.create(new FileInputStream(file));
- Sheet sheet = wb.getSheetAt(0);
- if (file.isFile() && file.exists()) {
- System.out.println("Selenium.xlsx open");
- }
- else {
- System.out.println("Selenium.xlsx either not exist"
- + " or can't open");
- }
- //J = row Number
- for (int j=6; j< sheet.getLastRowNum(); j++) {
- Row row = sheet.getRow(j);
- //gets Column number
- Cell issn_col = row.getCell(8);// Grabs all the Column ISSN
- Cell cummulative = row.getCell(2);
- //Grabs the Value of the Cell
- String cellData= issn_col.getStringCellValue();
- ISSN_List.add(cellData);
- }
- saved_issn = ISSN_List.toString();
- saved_issn = saved_issn.substring(1, saved_issn.length() - 1);
- System.out.println(saved_issn);
- System.setProperty("webdriver.chrome.driver", "C:\\chrome\\chromedriver.exe");
- String url ="https://www.scopus.com/customer/authenticate/loginfull.uri";
- String advanced_tab = "https://www.scopus.com/search/form.uri?display=advanced&origin=searchbasic&txGid=526775849ea4aa06b2c4852684f5e249";
- WebDriver driver = new ChromeDriver();
- driver.get(url);
- try{
- Assert.assertEquals(url, driver.getCurrentUrl());
- System.out.println("Navigated to correct webpage");
- }
- catch(Throwable pageNavigationError){
- System.out.println("Didn't navigate to correct webpage");
- }
- //Login to the account
- WebElement username = driver.findElement(By.id("username"));
- username.sendKeys(enter_email);
- WebElement password = driver.findElement(By.id("password-input-password"));
- password.sendKeys("westernsydney");
- WebElement submit_password = driver.findElement(By.id("login_submit_btn"));
- submit_password.submit();
- driver.get(advanced_tab);
- try{
- Assert.assertEquals(advanced_tab, driver.getCurrentUrl());
- System.out.println("Navigated to correct webpage");
- }
- catch(Throwable pageNavigationError){
- System.out.println("Didn't navigate to correct webpage");
- }
- saved_issn = "or ISSN(2161-2129), or ISSN(2150-7511), or ISSN(2210-6340), or ISSN(2210-6359), or ISSN(2077-7019)";
- setClipboardContents(saved_issn);
- driver.findElement(By.id("searchfield")).sendKeys(Keys.CONTROL +"v");
- driver.findElement(By.id("searchfield")).sendKeys(Keys.RETURN);
- //Checks the All the CheckBoxes
- if ( !driver.findElement(By.id("selectAllCheck")).isSelected() )
- {
- driver.findElement(By.id("selectAllCheck")).click();
- System.out.println("All select");
- }
- //Clicks on View Citation Overview
- WebElement view_citation = driver.findElement(By.id("ctoDocResultLink"));
- view_citation.click();
- WebDriverWait wait = new WebDriverWait(driver, 20);
- wait.until(ExpectedConditions.elementToBeClickable(By.id("closeBigCTODialog")));
- setClipboardContents(enter_email);
- driver.findElement(By.id("emailCTO")).sendKeys(Keys.CONTROL +"v");
- driver.findElement(By.id("emailCTO")).sendKeys(Keys.RETURN);
- System.out.println("Hello");
- }
- public static void setClipboardContents(String text) {
- StringSelection stringSelection = new StringSelection( text );
- Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
- clipboard.setContents(stringSelection, null);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement